gpt4 book ai didi

php - WordPress 主题定制器 - 无法添加部分/设置

转载 作者:行者123 更新时间:2023-12-02 22:06:26 26 4
gpt4 key购买 nike

我试图通过添加部分和设置来修改 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');

我本希望这会添加一个具有所选名称的部分,但我看到的唯一内容是 WordPress 的两个初始部分(网站标题和标语、静态首页)。

我在这里找到了一个非常好的教程( http://code.tutsplus.com/series/a-guide-to-the-wordpress-theme-customizer--wp-33722 )。我遵循了每一步,甚至采用了他们的示例主题,但同样,没有显示新的部分或设置。

让我怀疑我的配置是否有问题。

我正在使用 WordPress 网络/多站点,不知道这是否相关。

有什么想法吗?

谢谢洛朗

最佳答案

您需要添加设置和控件才能使其正常工作:

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');

引用:Theme Customization API .

关于php - WordPress 主题定制器 - 无法添加部分/设置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29446677/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com