1
我已经在我的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',
),
));
然后我有这个在我的单PHP文件,这是显示一个人的博客文章页面:
<?php if (get_theme_mod ('mytheme_comments' == 'On')) : ?>
<?php comments_template(); ?>
<?php elseif (get_theme_mod ('mytheme_comments' == 'Off')) : ?>
<?php endif ?>
的意见是默认关闭的,但选择从下拉菜单“上”,没有任何效果。
任何想法我可能做错了什么?
感谢您的支持。我已经尝试过进行更改,但由于某些原因,它仍未注册更改。 – user18577
@ user18577我可以看到你的更新代码..将完整的代码添加到pastbin – Baba
当然,在这里你去:http://pastebin.com/Yuka0nRK – user18577