Per Søderlind

I code for fun

  1. customizer
  2. WordPress Customizer Demo: In Twenty Sixteen, toggle post meta on or off

WordPress Customizer Demo: In Twenty Sixteen, toggle post meta on or off

customizer-post-meta

Purpose of this demo is to demonstrate, for the theme developer, how to use the customizer postmessage transport and a preview script to toggle complex theme elements on or off.

In this demo I’ll toggle displaying the author and post date.

Theme code:

When the post meta is toggled off, the theme will create an post meta wrapper without the post meta html, and the preview script doesn’t have anything to toggle:

I solve this by adding the missing html using jQuery.prependTo(). The html is just for the preview and will not be added to the theme:

You’ll find a complete demo at GitHub

Previous

Plugin Customizer: Ad WordPress customizer to a plugin

Next

WordPress linting using Code Climate, the Swiss Army knife of code linting

1 Comment

  1. Hi, on occasion I see a 404 site error when I view this page. I thought you may wish to know, cheers

Leave a Reply

Powered by WordPress & Theme by Anders Norén