You want to add a dropdown control in the Theme Customizer to select a font family with options 'Arial', 'Georgia', and 'Verdana'. Which code snippet correctly achieves this?
hard📝 Application Q8 of 15
Wordpress - Themes and Appearance
You want to add a dropdown control in the Theme Customizer to select a font family with options 'Arial', 'Georgia', and 'Verdana'. Which code snippet correctly achieves this?
The 'select' type creates a dropdown with multiple choices.
Step 2: Check choices format
Choices must be an associative array with keys and labels; $wp_customize->add_setting('font_family', ['default' => 'Arial']);
$wp_customize->add_control('font_family', ['type' => 'select', 'section' => 'typography', 'choices' => ['Arial' => 'Arial', 'Georgia' => 'Georgia', 'Verdana' => 'Verdana'], 'label' => 'Font Family']); uses correct format.
Step 3: Verify other options
$wp_customize->add_setting('font_family', ['default' => 'Arial']);
$wp_customize->add_control(new WP_Customize_Color_Control($wp_customize, 'font_family', ['section' => 'typography', 'label' => 'Font Family'])); uses color control incorrectly; C uses radio with wrong choices format; A uses text input instead of dropdown.
Final Answer:
Code snippet with 'select' type and associative choices array -> Option D
Quick Check:
Dropdown needs 'select' type and choices array [OK]
Quick Trick:Use 'type' => 'select' and 'choices' array for dropdowns [OK]
Common Mistakes:
Using color control for non-color settings
Incorrect choices array format
Using 'text' instead of 'select' for dropdown
Master "Themes and Appearance" in Wordpress
9 interactive learning modes - each teaches the same concept differently