Wordpressサイトのfunctions.phpファイルで次の関数を定義しました。コメントをオンまたはオフにするオプションが表示されます。
$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',
        ),
) );
次に、これをsingle.phpファイルに入れます。これは、個々のブログ投稿を表示するページです。
<?php if (get_theme_mod ( 'mytheme_comments' == 'On' ) ) : ?>
<?php comments_template(); ?>
<?php elseif (get_theme_mod ( 'mytheme_comments' == 'Off' ) ) : ?>
<?php endif ?>
コメントはデフォルトでオフになっていますが、ドロップダウンから「オン」を選択しても効果はありません。
私が間違っているかもしれないアイデアはありますか?