i am building a theme for WordPress and i have set all the get theme mods and everything works fine.

Now my question is related to the options. I have a get_the_mod which has a type=>textarea in customizer.php but i want to add a type=>checkbox also.

I want to write a comditional like if the checkbox is selected then show the textarea option otherwise not my get_theme_mod is like

         <?php if (get_theme_mod('footer_tauthor') != ""){
     echo get_theme_mod('footer_tauthor');
 } else {
     echo 'Website Runs on openBlogger by <a href="yo.com">YOyo</a>';

what i can do to make it check box first, then text area if selected by user. the customizer control is like

$wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'footer_tauthor',
'label' => 'Update Footer Copyright Text',
'type' => 'textarea',
'section'  => 'site_footer',
'settings' => 'footer_tauthor',
) ) );

thanks in advance


you can define the conditional display on definition in PHP with that in the arguments array of footer_tauthor

$wp_customize->add_control( new WP_Customize_Control( $wp_customize, 'footer_tauthor',
        // other args ...
        "active_callback" => function ($control) {
            return $control->manager->get_setting("checkboxSettingName")->value();
) );
  • will you please elaborate your answer Aug 8 '18 at 4:43
  • I edited my answer. Aug 8 '18 at 4:46
  • what actually it does (code) in plain english i mean and also what checkboxsettingname represents Aug 8 '18 at 4:48
  • edit your question to add the whole code that you use for registering the checkbox. Aug 8 '18 at 5:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.