Bird
0
0

Identify the error in this Theme Customizer code snippet:

medium📝 Debug Q14 of 15
Wordpress - Themes and Appearance
Identify the error in this Theme Customizer code snippet:
 $wp_customize->add_setting('footer_text', [
  'default' => 'Footer here',
  'sanitize_callback' => 'sanitize_text_field'
]);
$wp_customize->add_control('footer_text', [
  'label' => 'Footer Text',
  'section' => 'footer_section',
  'type' => 'textarea'
]);
Assuming 'footer_section' was never added, what issue will occur?
AThe control will not display because the section does not exist
BThe setting will fail to save user input
CThe sanitize_callback will cause a fatal error
DThe default value will be ignored
Step-by-Step Solution
Solution:
  1. Step 1: Check if the section exists

    The control references 'footer_section', but this section was never added with add_section().
  2. Step 2: Understand control behavior without a valid section

    Controls must belong to existing sections; otherwise, they won't display in the Customizer UI.
  3. Final Answer:

    The control will not display because the section does not exist -> Option A
  4. Quick Check:

    Control needs valid section to display = true [OK]
Quick Trick: Controls need existing sections to show [OK]
Common Mistakes:
  • Assuming setting fails to save without section
  • Thinking sanitize_callback causes error here
  • Believing default value is ignored

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Wordpress Quizzes