0

Hi. I'm trying to create a custom meta box on Wordpress with multiple text fields.

The idea is that there is initially one text box, then you can click the button 'Add New' and a another text box is added. This needs to be via Ajax; using Javascript doesn't physically create the HTML and I have to use a PHP foreach loop to get all of the values from and combine them into an array in order to be saved.

Currently via PHP I've created a foreach loop that creates a text box for each value from the custom field (etc, 3 text boxes). I want to create a button that when clicked, it will add another blank text box as part of this foreach loop. When the post is saved, it will get the values from the 4 text boxes and save them back into the array.

Is this possible? Pulling my hair out over this!

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by Airshow
0

Matthew,

You could try to install a working example of add_meta_box (eg. this one), then set about modifying it to your own specification.

I don't pretend to understand everything in the example, but it would appear that downstream client-side and server-side handling is managed automatically.

Airshow

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.