我在WordPress customr.php中创建了“选项”面板:
// Add theme options panel.
$wp_customize->add_panel(
'anvitest-lite', array(
'title' => esc_html__( 'Theme Options', 'anvitest-lite' ),
'priority' => 11,
)
);
比我添加了一段:
$wp_customize->add_section(
'title_section', array(
'title' => esc_html__( 'Main Screen Section', 'anvitest-lite' ),
'panel' => 'anvitest-lite',
)
);
到目前为止,一切正常。但是在本节中,我需要显示四个带有联系人的字段(邮件,地址和电话号码)。我创建了字段:
/**************************email_field****************************/
$wp_customize->add_setting(
'email_field', array(
'default' => ''
)
);
$wp_customize->add_control(
'title_section', array(
'label' => esc_html__( 'Enter E-mail', 'anvitest-lite' ),
'section' => 'title_section',
'settings' => 'email_field',
'type' => 'email',
'description' => esc_html__( 'Enter your mail in this field', 'anvitest-lite' ),
)
);
/**************************phone_field****************************/
$wp_customize->add_setting(
'phone_field', array(
'default' => ''
)
);
$wp_customize->add_control(
'title_section', array(
'label' => esc_html__( 'Enter Phone', 'anvitest-lite' ),
'section' => 'title_section',
'settings' => 'phone_field',
'type' => 'text',
'description' => esc_html__( 'Enter your phone in this field', 'anvitest-lite' ),
)
);
/**************************adress_field****************************/
$wp_customize->add_setting(
'adress_field', array(
'default' => ''
)
);
$wp_customize->add_control(
'title_section', array(
'label' => esc_html__( 'Enter Adress', 'anvitest-lite' ),
'section' => 'title_section',
'settings' => 'adress_field',
'type' => 'text',
'description' => esc_html__( 'Enter your adress in this field', 'anvitest-lite' ),
)
);
但是,由此在此定制器中仅显示用于输入电子邮件地址的字段。参见屏幕:http://prntscr.com/nt891d。请告诉我我在做什么错。谢谢!
答案 0 :(得分:0)
我找到了解决方案。这是代码:
$wp_customize->add_panel(
'anvitest-lite',[
'title' => esc_html__( 'Theme Options', 'anvitest-lite' ),
'priority' => 11,
]
);
$wp_customize->add_section(
'title_section', [
'title' => esc_html__( 'Main Screen Section', 'anvitest-lite' ),
'panel' => 'anvitest-lite',
'priority' => 200,
]
);
$wp_customize->add_setting(
'email_field', array(
'default' => ''
)
);
$wp_customize->add_control(
'email_field', array(
'section' => 'title_section',
'type' => 'email',
'description' => esc_html__( 'Enter your mail in this field', 'anvitest-lite' ),
)
);
/**************************phone_field****************************/
$wp_customize->add_setting(
'phone_field', array(
'default' => ''
)
);
$wp_customize->add_control(
'phone_field', array(
'label' => esc_html__( 'Enter Phone', 'anvitest-lite' ),
'section' => 'title_section',
'type' => 'text',
'description' => esc_html__( 'Enter your phone in this field', 'anvitest-lite' ),
)
);
/**************************adress_field****************************/
$wp_customize->add_setting(
'adress_field', array(
'default' => ''
)
);
$wp_customize->add_control(
'adress_field', array(
'label' => esc_html__( 'Enter Adress', 'anvitest-lite' ),
'section' => 'title_section',
'type' => 'text',
'description' => esc_html__( 'Enter your adress in this field', 'anvitest-lite' ),
)
);