WP主题定制器 - 选项顺序

时间:2013-04-11 16:48:12

标签: wordpress wordpress-theming

我遇到了主题定制器的问题。我的代码是:

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

问题在于此。在管理面板视图中

第二种选择, 第一种选择, 标题, 第三种选择,

谁能知道,我做错了什么?你可以帮帮我吗?我会感恩的

1 个答案:

答案 0 :(得分:7)

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

例如:

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