Customizer JS API dynamically add sections and controls

What you are looking for here is already 80% available already, if you use the Customize Posts plugin and enable the Testimonials content type in Jetpack. Sections for testimonial posts can be listed in a Testimonials panel, in addition to a Select2 to jump to one:

List of testimonials

And then when expanding the testimonial section there are fields for the name and featured image and others:

Testimonial fields

You’ll note that there is currently a lack of a “order” field. For that, you’ll want to follow:

Also, you’ll note that the panel does not show all of the posts of that type when it is expanded. Sections are currently added as they appear in the preview or as they are added via the Select2 dropdown. For listing all posts, you can follow List all posts of a given post type in the section.

As for adding custom fields to a custom post type, such as extending the Jetpack Testimonials, you could refer to the examples of adding postmeta in Customize Posts (featured image and page template) or you could look at this new standalone example (which is still rough and needs to be refined).

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)