wordpress custom fields multiple data

i need help with wordpress custom fields currently i store date in one custom field called audio using the “,” and “$” example:
name, link $ name, link $ etc
i have managed to use the data and split the data using php in my theme i.e the playlist.
i just need help in creating a custom metabox with 2 text fields that can be duplicated by clicking on adding more and two more fields would show. i only want to use only one custom field to store the data.

thanks

Related posts

Leave a Reply

1 comment

  1. You can store an array in a custom field; WordPress serializes it for you on save and unserializes it on get.

    Name your fields with a pseudo array syntax:

    <input name="mycustomfield[audio]">
    <input name="mycustomfield[date]">
    

    You’ll get a $_POST array:

    mycustomfield = array ( 'audio' => 'somevalue', 'date' => 'somedate' )
    

    Now you can do whatever you want with it.

    Drawback: Meta queries against serialized arrays are hard. Multiple post meta field are much easier to handle.