I am working on creating custom meta boxes for the back-end of WordPress.
I would like to add a metabox with several fields, in my case an image upload and a text input, but with a button that can duplicate both fields.
I've been following this tutorial and it works fine.
But since I want to duplicate multiple fields (as mentioned earlier, the media uploader and text input), the above tutorial does not quite fit. There is only 1 input text used.
Now I have found the following source code, which corresponds somewhat to my wishes:
This makes it possible to have multiple cases in a repeatable field stop (this is what I want), only the code is far too extensive and is in a PHP class. Now I want this code into that of the tutorial, just try and get this to many trials for each other.
Now I wonder if anyone can help me with this. I've tried many things and work to date yet.
When I see the source code, I do not really need the piece and there will be more redundant than necessary.
I've also tried the simple case repeatable to copy / paste, but I get errors, including that some variable does not exist. (These are, as I see it also hell once declared nowhere ...)
Unfortunately gives these errors are, as I said, namely:
Notice: Undefined variable: repeatable_fields in on line 117
Warning: Invalid argument supp song for foreach () in
Warning: array_filter () Expects parameter 1 to be array,
null Given in /file/ on line 118
Notice: Uninitialized string offset: 0 in on
Code can be viewed at: http://snippi.com/s/xpwucxg
How can I duplicate multiple fields?