Repeater field in Customizer

I'd like to develop a settingcontrol for Customizer that allows dynamically to add fields. The typical example wou

I'd like to develop a setting/control for Customizer that allows dynamically to add fields. The typical example would be the possibility to add an unlimited number of slides to an slider in a Theme. There would be a button in the Customizer setting called "Add new slide" that allows to add a new slide field.

For the sake of the responses, let's make it easy: Just a text field per row. So each time we click on a "Add new row" button, a new text field is generated.

I've tried different approaches and my latest one was an attempt to use script templates (Mustache) like this example:

The problem is how to handle dynamically those settings? How to use the WP_Customize_Control to_json function and how to get that Mustache template and duplicate it every time we click on the "Add new" button? I have a very good background on PHP and a medium level on JS so I can understand advanced topics.

I'd like to develop a setting/control for Customizer that allows dynamically to add fields. The typical example would be the possibility to add an unlimited number of slides to an slider in a Theme. There would be a button in the Customizer setting called "Add new slide" that allows to add a new slide field.

For the sake of the responses, let's make it easy: Just a text field per row. So each time we click on a "Add new row" button, a new text field is generated.

I've tried different approaches and my latest one was an attempt to use script templates (Mustache) like this example: http://justintadlock/archives/2015/06/05/javascript-templating-in-the-wordpress-customizer

The problem is how to handle dynamically those settings? How to use the WP_Customize_Control to_json function and how to get that Mustache template and duplicate it every time we click on the "Add new" button? I have a very good background on PHP and a medium level on JS so I can understand advanced topics.

Share Improve this question asked Aug 31, 2015 at 17:06 IgnacioIgnacio 711 silver badge3 bronze badges
Add a comment  | 

2 Answers 2

Reset to default 6

You could use or take a reference from Kirki. It is a framework that allow to add customizer controls with less code.

Take a look to Kirki::Repeater_Control here.

This is awesome,have a look it's the best https://github/cristian-ungureanu/customizer-repeater

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745361357a4624375.html

相关推荐

  • Repeater field in Customizer

    I'd like to develop a settingcontrol for Customizer that allows dynamically to add fields. The typical example wou

    4小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信