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