1

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

  • I don't understand this question at all. Why are you storing the date in a field called audio? Why not use multiple custom fields instead of trying to implement your own serialisation? What 2 fields do you want to show when you click on a button? – anu May 23 '11 at 10:32
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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.