我试图通过添加部分和设置来修改Worpdress主题定制器,但无论我在functions.php文件中添加什么,都没有在定制器中显示任何内容.
例:
function starter_customize_register( $wp_customize )
{
$wp_customize->add_section( 'mytheme_new_section_name' , array(
'title' => __( 'Visible Section Name', 'starter' ),
'priority' => 30, ) );
}
add_action( 'customize_register', 'starter_customize_register');
Run Code Online (Sandbox Code Playgroud)
我希望这会添加一个带有所选名称的部分,但我看到的唯一内容是来自Wordpress的两个初始部分(网站标题和标语,静态首页).
我在这里找到了一个非常好的教程(http://code.tutsplus.com/series/a-guide-to-the-wordpress-theme-customizer--wp-33722).我按照每一步,甚至采用了他们的示例主题,但又一次,没有显示新的部分或设置.
让我想知道我的配置是否有问题.
我正在使用wordpress网络/多站点,不知道这是否相关.
任何的想法?
谢谢Laurent
d79*_*d79 27
您需要添加设置和控件才能使其工作:
function starter_customize_register( $wp_customize )
{
$wp_customize->add_section( 'starter_new_section_name' , array(
'title' => __( 'Visible Section Name', 'starter' ),
'priority' => 30
) );
$wp_customize->add_setting( 'starter_new_setting_name' , array(
'default' => '#000000',
'transport' => 'refresh',
) );
$wp_customize->add_control( new WP_Customize_Color_Control( $wp_customize, 'link_color', array(
'label' => __( 'Header Color', 'starter' ),
'section' => 'starter_new_section_name',
'settings' => 'starter_new_setting_name',
) ) );
}
add_action( 'customize_register', 'starter_customize_register');
Run Code Online (Sandbox Code Playgroud)
参考:主题定制API.
| 归档时间: |
|
| 查看次数: |
7965 次 |
| 最近记录: |