WP主题定制器 - 选项顺序

hquae 发布于 2019-03-09 wordpress 最后更新 2019-03-09 14:42 3 浏览

主题定制工具有问题。我的代码是:

function candyfloss_theme_customizer( $wp_customize ) { 
    class Heading extends WP_Customize_Control {
    public $type = 'heading';
public function render_content() {
        ?>
        <label>
        <span class="customize-control-title" style="border-bottom: 1px dashed #666;"><strong><?php echo esc_html( $this->label ); ?></strong></span>            
        </label>
        <?php
    }
}
$wp_customize->add_setting('products_heading', array(
    'default',
) );
$wp_customize->add_control(new Heading ($wp_customize, 'products_heading', array(
    'label' => __('Home - products section'),
    'type' => 'heading',
    'section' => 'home',        
) ) );
$wp_customize->add_setting('candyfloss_product_first', array(
    'deafault',
) );
$wp_customize->add_control('candyfloss_product_first', array(
    'label' => __('First product page'),
    'type' => 'dropdown-pages',
    'section' => 'home',        
) );
$wp_customize->add_setting('candyfloss_product_second', array(
    'deafault',
) );
$wp_customize->add_control('candyfloss_product_second', array(
    'label' => __('Second product page'),
    'type' => 'dropdown-pages',
    'section' => 'home',
) );
$wp_customize->add_setting('candyfloss_product_third', array(
    'deafault',
) );
$wp_customize->add_control('candyfloss_product_third', array(
    'label' => __('Third product page'),
    'type' => 'dropdown-pages',
    'section' => 'home',
) );
};
add_action( 'customize_register', 'candyfloss_theme_customizer', 11 );
问题在于此。在管理面板视图是 第二选择, 第一种选择, 标题, 第三种选择, 谁能知道,我做错了什么?你可以帮帮我吗?我会很感激
已邀请:

jvitae

赞同来自:

我找到了答案。 Wordpress为控件提供随机优先级。要解决它,我们只需要为每个控件添加优先级编号。 例如。:

$wp_customize->add_control(new Heading ($wp_customize, 'products_heading', array(
    'label' => __('Home - products section'),
    'type' => 'heading',
    'section' => 'home',
    'priority' => 2,        
) ) );