admin管理员组文章数量:1417442
I added a section to the customizer and everything worked fine. But after I added a second one the first one no longer appears. At first I thought that I had not changed the section ID, but that was not the case. Here is some of my code:
/* ====================================================
* Section 1
=================================================== */
// Add section
$wp_customize->add_section("qs_spirit_co_section_1", array(
"title" => __("First Widget Area", "qs-spirit-co"),
"priority" => 1,
"panel" => "widget_section_panel",
));
// Section 1 text color
$wp_customize->add_setting("qs_spirit_co_section_1_text_color", array(
"default" => "#f8f8f8",
"transport" => "refresh",
));
$wp_customize->add_control(new WP_Customize_Color_Control(
$wp_customize, "qs_spirit_co_section_2_text_color_control",
array(
"label" => __("Text Color", "qs-spirit-co"),
"section" => "qs_spirit_co_section_1",
"settings" => "qs_spirit_co_section_1_text_color",
"type" => "color",
)
));
/* ====================================================
* Section 2
=================================================== */
// Add section
$wp_customize->add_section("qs_spirit_co_section_2", array(
"title" => __("Second Widget Area", "qs-spirit-co"),
"priority" => 130,
"panel" => "widget_section_panel",
));
// Section 2 text color
$wp_customize->add_setting("qs_spirit_co_section_2_text_color", array(
"default" => "#535353",
"transport" => "refresh",
));
$wp_customize->add_control(new WP_Customize_Color_Control(
$wp_customize, "qs_spirit_co_section_2_text_color_control",
array(
"label" => __("Text Color", "qs-spirit-co"),
"section" => "qs_spirit_co_section_2",
"settings" => "qs_spirit_co_section_2_text_color",
"type" => "color",
)
));
I even made a new panel for these sections but the first one still does not show when the second one is there. I removed the code for the second and the first appeared again.
I'm probably just missing something simple but I haven't found it yet. Could someone please help?
I added a section to the customizer and everything worked fine. But after I added a second one the first one no longer appears. At first I thought that I had not changed the section ID, but that was not the case. Here is some of my code:
/* ====================================================
* Section 1
=================================================== */
// Add section
$wp_customize->add_section("qs_spirit_co_section_1", array(
"title" => __("First Widget Area", "qs-spirit-co"),
"priority" => 1,
"panel" => "widget_section_panel",
));
// Section 1 text color
$wp_customize->add_setting("qs_spirit_co_section_1_text_color", array(
"default" => "#f8f8f8",
"transport" => "refresh",
));
$wp_customize->add_control(new WP_Customize_Color_Control(
$wp_customize, "qs_spirit_co_section_2_text_color_control",
array(
"label" => __("Text Color", "qs-spirit-co"),
"section" => "qs_spirit_co_section_1",
"settings" => "qs_spirit_co_section_1_text_color",
"type" => "color",
)
));
/* ====================================================
* Section 2
=================================================== */
// Add section
$wp_customize->add_section("qs_spirit_co_section_2", array(
"title" => __("Second Widget Area", "qs-spirit-co"),
"priority" => 130,
"panel" => "widget_section_panel",
));
// Section 2 text color
$wp_customize->add_setting("qs_spirit_co_section_2_text_color", array(
"default" => "#535353",
"transport" => "refresh",
));
$wp_customize->add_control(new WP_Customize_Color_Control(
$wp_customize, "qs_spirit_co_section_2_text_color_control",
array(
"label" => __("Text Color", "qs-spirit-co"),
"section" => "qs_spirit_co_section_2",
"settings" => "qs_spirit_co_section_2_text_color",
"type" => "color",
)
));
I even made a new panel for these sections but the first one still does not show when the second one is there. I removed the code for the second and the first appeared again.
I'm probably just missing something simple but I haven't found it yet. Could someone please help?
Share Improve this question asked Aug 8, 2019 at 3:01 TLawsonTLawson 11 bronze badge1 Answer
Reset to default 1The problem is that you've got duplicate control IDs. In section 1 you have:
$wp_customize->add_control(new WP_Customize_Color_Control(
$wp_customize, "qs_spirit_co_section_2_text_color_control",
array(
"label" => __("Text Color", "qs-spirit-co"),
"section" => "qs_spirit_co_section_1",
"settings" => "qs_spirit_co_section_1_text_color",
"type" => "color",
)
));
Which has qs_spirit_co_section_2_text_color_control
as the ID.
And in section 2 you have:
$wp_customize->add_control(new WP_Customize_Color_Control(
$wp_customize, "qs_spirit_co_section_2_text_color_control",
array(
"label" => __("Text Color", "qs-spirit-co"),
"section" => "qs_spirit_co_section_2",
"settings" => "qs_spirit_co_section_2_text_color",
"type" => "color",
)
));
Which is also using qs_spirit_co_section_2_text_color_control
as the ID.
This means that only the first control is being added, to section 1, which means that section 2 has has no controls, and when sections have no controls they do not appear.
Make sure to give the controls unique IDs.
本文标签: Customizer section gone after adding second
版权声明:本文标题:Customizer section gone after adding second 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745260992a2650357.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论