I have defined the following function in my Wordpress site's functions.php file, it should give the option to turn comments on or off:
$wp_customize->add_section( 'display_comments', array(
'title' => 'Comments',
'priority' => 36,
) );
$wp_customize->add_setting( 'mytheme_comments' );
$wp_customize->add_control( 'mytheme_comments', array(
'label' => 'Comments on or off',
'section' => 'display_comments',
'type' => 'select',
'default' => 'Off',
'choices' => array(
'value1' => 'On',
'value2' => 'Off',
),
) );
I then have this in my single.php file, which is the page that shows an individual blog post:
<?php if (get_theme_mod ( 'mytheme_comments' == 'On' ) ) : ?>
<?php comments_template(); ?>
<?php elseif (get_theme_mod ( 'mytheme_comments' == 'Off' ) ) : ?>
<?php endif ?>
The comments are off by default, but choosing 'on' from the dropdown, does not have any effect.
Any ideas what I might be doing wrong?