How to make individual metabox fields duplicate?

Now I am coding a plugin for the WordPress admin. This is about special meta boxes. I would like to create a slideshow plugin, just to learn a lot of encodings.

I created one exchange containing the image upload and text input field. (see picture below)

Here is the metabox with the fields

So, I can save the fields, so I can load the image and set a text field in it. When I save a post / page inside WordPress, it will save the values ​​for me in my database. It's fine!

Now I would like to extend the code using the ability to add and remove fields, for example, a repeating field.
As you can see in the image above, I created a new slide button, I also have javascript code for it to work, but it does not work correctly.

So my question for you is the best way to create dynamic fields?
Now I use the clone function in javascript to clone the fields, but only the default string will work.

I spent several weeks with him and have not yet found a solution.

Some codes:
This is my metabolism code created using PHP.
This is the jQuery / Javascript that I am using now.

+5
source share
1 answer

WordPress StackExchange.
" ".

:

  • - WPSE Q & A

  • - Gist

    /**
     * Repeatable Custom Fields in a Metabox
     * Author: Helen Hou-Sandi
     *
     * From a bespoke system, so currently not modular - will fix soon
     * Note that this particular metadata is saved as one multidimensional array (serialized)
     */
    
  • - Gist,

+13

All Articles