Bird
0
0

Why does this Theme Customizer code cause a fatal error?

medium📝 Debug Q7 of 15
Wordpress - Themes and Appearance
Why does this Theme Customizer code cause a fatal error?
$wp_customize->add_control(new WP_Customize_Control($wp_customize, 'footer_text', ['label' => 'Footer Text']));
AThe setting 'footer_text' is not registered before adding the control
BThe 'section' parameter is missing in the control arguments
CThe control ID must be numeric
DWP_Customize_Control cannot be instantiated directly
Step-by-Step Solution
Solution:
  1. Step 1: Check if setting is registered

    The control references 'footer_text' setting, but no add_setting() call exists for it.
  2. Step 2: Understand control dependencies

    Controls require a registered setting; missing setting causes fatal error.
  3. Final Answer:

    The setting 'footer_text' is not registered before adding the control -> Option A
  4. Quick Check:

    Control needs existing setting [OK]
Quick Trick: Register setting before adding its control [OK]
Common Mistakes:
  • Omitting add_setting() for control's setting
  • Assuming 'section' is always required (optional if default)

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Wordpress Quizzes