4

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

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

问题是这样的。在管理面板视图是

第二个选项,第一个选项,标题,第三个选项,

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

4

1 回答 1

7

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

例如。:

$wp_customize->add_control(new Heading ($wp_customize, 'products_heading', array(
    'label' => __('Home - products section'),
    'type' => 'heading',
    'section' => 'home',
    'priority' => 2,        
) ) );
于 2013-04-12T00:53:07.177 回答