Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wordpress WP主题定制器-选项顺序_Wordpress_Wordpress Theming - Fatal编程技术网

Wordpress WP主题定制器-选项顺序

Wordpress WP主题定制器-选项顺序,wordpress,wordpress-theming,Wordpress,Wordpress Theming,我对主题定制器有问题。我的代码是: function candyfloss_theme_customizer( $wp_customize ) { class Heading extends WP_Customize_Control { public $type = 'heading'; public function render_content() { ?> <label> <span cla

我对主题定制器有问题。我的代码是:

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 );
function candyfloss\u theme\u customizer($wp\u customize){
类标题扩展了WP\u自定义\u控件{
公共$type='标题';
公共函数render_content(){
?>


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

例如:

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