我在索引中有一个设置。php
if(get_option(\'cb2_blog_home\')){
cb_get_blog_links();
}
此代码允许打开和关闭主页博客索引。cb\\u get\\u blog\\u links()函数用于绘制日志摘要列表。
而且,在customizer中,我有一个复选框,允许设置这个值cb2\\u blog\\u home。然而,它没有任何效果。似乎这个选项总是正确的。
知道为什么吗?
在该函数中,有几个变量,我也在使用customizer进行设置。这些都很好用。
以下是完整的自定义程序代码。除了主页博客设置外,一切都很完美。我唯一能想到的是,一个是函数,另一个是函数中的变量。
function cb_customize_register($wp_customize){
$wp_customize->add_section(\'cb_customizer_blog\', array(
\'title\' => __(\'Theme Blog Settings\', \'Theme\'),
\'priority\' => 120,
));
//Show & Hide Blog Links on Home
$wp_customize->add_setting(\'cb2_blog_home\', array(
\'default\' => \'\',
\'capability\' => \'edit_theme_options\',
\'type\' => \'option\',
));
$wp_customize->add_control(\'cb2_blog_home\', array(
\'label\' => __(\'Enable Home Blog\', \'Theme\'),
\'section\' => \'cb_customizer_blog\',
\'settings\' => \'cb2_blog_home\',
\'type\' => \'checkbox\',
\'priority\' => 125,
));
//Home Blog Post Count
$wp_customize->add_setting(\'cb2_blog_home_count\', array(
\'default\' => \'3\',
\'capability\' => \'edit_theme_options\',
\'type\' => \'option\',
));
$wp_customize->add_control(\'cb2_blog_home_count\', array(
\'label\' => __(\'Home Blog Post Count\', \'Theme\'),
\'section\' => \'cb_customizer_blog\',
\'settings\' => \'cb2_blog_home_count\',
\'priority\' => 130,
));
//Show & Hide Home Blog Title Heading
$wp_customize->add_setting(\'cb2_blog_home_title_hide\', array(
\'default\' => \'\',
\'capability\' => \'edit_theme_options\',
\'type\' => \'option\',
));
$wp_customize->add_control(\'cb2_blog_home_title_hide\', array(
\'label\' => __(\'Hide Home Blog Title\', \'Theme\'),
\'section\' => \'cb_customizer_blog\',
\'settings\' => \'cb2_blog_home_title_hide\',
\'type\' => \'checkbox\',
\'priority\' => 135,
));
//Show & Hide Home Blog Author Byline
$wp_customize->add_setting(\'cb2_blog_index_author\', array(
\'default\' => \'\',
\'capability\' => \'edit_theme_options\',
\'type\' => \'option\',
));
$wp_customize->add_control(\'cb2_blog_index_author\', array(
\'label\' => __(\'Hide Blog Author Byline\', \'Theme\'),
\'section\' => \'cb_customizer_blog\',
\'settings\' => \'cb2_blog_index_author\',
\'type\' => \'checkbox\',
\'priority\' => 140,
));
//Show & Hide Home Blog Date
$wp_customize->add_setting(\'cb2_blog_index_date\', array(
\'default\' => \'\',
\'capability\' => \'edit_theme_options\',
\'type\' => \'option\',
));
$wp_customize->add_control(\'cb2_blog_index_date\', array(
\'label\' => __(\'Hide Blog Date\', \'Theme\'),
\'section\' => \'cb_customizer_blog\',
\'settings\' => \'cb2_blog_index_date\',
\'type\' => \'checkbox\',
\'priority\' => 145,
));
}
add_action(\'customize_register\', \'cb_customize_register\');