Bird
0
0

Identify the error in this Theme Customizer code:

medium📝 Debug Q6 of 15
Wordpress - Themes and Appearance
Identify the error in this Theme Customizer code:
$wp_customize->add_setting('header_text', ['default' => 'Welcome']);
$wp_customize->add_control('header_text', ['label' => 'Header Text', 'section' => 'header']);
AThe code is correct and will work as expected
BThe add_setting() method is missing required parameters
CThe 'header' section is not added before adding the control
DThe control ID should be different from the setting ID
Step-by-Step Solution
Solution:
  1. Step 1: Check if 'header' section exists

    The code does not add a 'header' section before adding a control to it, which causes the control not to appear.
  2. Step 2: Verify setting and control IDs

    Using the same ID for setting and control is correct; add_setting() parameters are sufficient.
  3. Final Answer:

    The 'header' section is not added before adding the control -> Option C
  4. Quick Check:

    Missing section causes control not to show [OK]
Quick Trick: Always add sections before adding controls to them [OK]
Common Mistakes:
  • Assuming control appears without its section
  • Thinking setting and control IDs must differ

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Wordpress Quizzes