I was able to solve this. Here is the code that got the checkbox working.
function theme_customizer_register_checkbox($wp_customize) {
$wp_customize->add_section( 'global_options', array(
'title' => 'Global Options',
) );
$wp_customize->add_setting( 'show_supporters', array(
'default' => true,
'transport' => 'postMessage'
) );
$wp_customize->add_control(
'show_supporters',
array(
'section' => 'global_options',
'label' => 'Show supporters section?',
'type' => 'checkbox'
)
);
}
add_action( 'customize_register', 'theme_customizer_register_checkbox' );
Then I checked for the value in the front end like so
if(true === get_theme_mod('show_supporters')){ do something here }
Related Posts:
- Use default value of wp_customizer in theme_mod output?
- get_theme_mod doesn’t return the theme customizer preview’s new values in after_setup_theme hook
- Why does get_theme_mod return blank (or default value) but get_option returns saved value?
- Why is remove_setting and remove_control not working?
- Get_theme_mod not retrieving value
- get_theme_mod not working
- get_theme_mod() only working when the customizer is open
- Customizer live preview not working, refreshes but nothing change
- get_theme_mod only returns false
- get_theme_mod filter ignores sanitize_callback
- Fetch customizer image and output as an inline css style background image
- How to properly delete and rename the custom settings/section/control in theme customizer?
- get_option() vs get_theme_mod(): Why is one slower?
- Different customizer previewUrls per section
- Add custom background to div in home page
- How do I handle the “WP_Customize_Cropped_Image_Control” callback?
- Make Theme Options Native to Theme Customizer
- Can I change a control’s transport in Customizer depending on the previewed page?
- Passing data from customize-controls.js to the customize-preview.js
- Get attachment id from WP Customizer
- How to output WP_Customize_Cropped_Image_Control setting?
- Deactivate sections/panels when the Customizer finishes loading
- Need to run a plugin on Customize.php
- Customizer preview doesn’t update get_option() value properly
- Set Default Page On Customizer Live Preview
- How to hide few theme customization options – TwentySeventeen theme
- Does the customizer support multiple templates?
- How can a default site icon be set in customizer?
- New customizer setting not showing value
- Removing pre existing menu item
- How to make get_theme_mod work with AJAX in the customizer preview
- get_theme_mod is returning a number rather than my image file
- Theme customization based on grouped pages
- Change the location of add_theme_support( ‘custom-header’ ) in the customizer
- Customizer: Update Preview instantly when typing into a number input field
- add_theme_support(‘custom-header’) does not add the option to customize
- Create custom control for WordPress customizer using JavaScript
- Customizer Not Applying Any Change, No Error Thrown
- Custom panel/section link styling in customizer
- How to Get WP_Customize_Image_Control content?
- Custom switch not hiding sub-fields on Customizer’s load
- WordPress Customizer Selective Refresh: works only on first setting change
- How to use WP_Customize_Cropped_Image_Control settings in the customizer preview?
- How to use Vuejs inside a custom control?
- WordPress Customizer: Why widgets and nav_menus are components, not panel or section?
- Customizer Ajax
- Add post type titles in customizer dropdown list
- How to make a Customizer partial force full refresh instantly?
- Place a message in theme customizer sidebar
- How to add width & height (resolution) on wordpress function?
- WordPress Customizer Panels in separate files
- Function has_custom_logo when used in Customizer
- WordPress Include ‘print_f’ in WP_Customize_Control array [closed]
- Override theme style rule in Gutenberg
- How to add custom classes to the customizer panels, sections or controls?
- Theme Check plugin error when I add ‘©’ [closed]
- doubble scroll bar on wordpress home page [closed]
- Theme Customize API Panel Concept
- Detect device change (desktop, tablet or mobile) in Customizer
- Kirki: generate toggles for each taxonomy term
- Allow multiple settings to be stored in a single option in Theme customizer
- Theme customizer not working
- How do you add a link in the description of one section of the customizer to another section in a different panel?
- get_theme_mod outputs number when using WP_Customize_Cropped_Image_Control
- When deleting a theme, are the theme customizer settings also deleted from the database?
- Get WordPress page Id inside customizer
- How to Add new Arguments to custom Control of customizer wordpress?
- Unexpected output using theme customizer
- Customizer List of Items
- Prevent WordPress from setting src on image added in Customiser
- How would you set Theme Customizer API Previewer Preview URL of a Logged out Page or Login Screen
- Twentyseventeen theme customize bug
- Defining path of content folder in WP-config solves the issue of missing header, footer, theme options. Is this a good approach? Expert Advice needed
- How to save theme customizer values as sub-array?
- customizer refresh breaks with this code but I don’t understand why
- Change a customizer control based on another control’s value dynamically
- Is there a way to load translations from .PO and .MO files for Customizer strings?
- Image Uploaded To Customizer Not Displaying
- Can I fake being in the customizer?
- Domain redirect seems to break WP customizer
- Top header to edit page not present in one page
- WordPress Customizer not allowing menu options
- In 2016 Theme where is the Posts page thumbnail image stored?
- I need to get the control choices to sanitize_callback
- Edit style.css via theme customizer
- Customizer Get Control Choices on Change
- How do I flush a conditioned control’s value if the parent control has been unchecked?
- input type=”button” not working in customizer
- How to implement Selective Refresh within posts?
- Location of customizer Menu panel core code
- Why my first new WP_Customize_Image_Control doesn’t work
- How to add a Visual Edit Shortcut to a theme mod?
- Return customizer setting value in functions.php
- Return value of get_background_color
- Let user select file in customizer
- Customizer_register not saving custom setting to database
- New Customizer Menu (WP 4.3) – how is called?
- Custom Sanitation Function Triggering an Alert in Customizer?
- How to tell theme customizer to save setting in my option table?
- Issue displaying customiser setting with get_theme_mod