I have a WordPress site that uses a bespoke theme. I’d like to add a feature toggle (checkbox setting) somewhere in the admin that can be read by the various theme pages to change their behavior.
What’s the best way to implement this? If you could include how I could then read that setting, it would be appreciated.
Use the Theme Customization API for that. A checkbox is not within the default controls, so a custom control has to be built.
This goes in
functions.php
:And in
header.php
:Results in: