Bird
0
0

Consider this code snippet:

medium📝 state output Q5 of 15
Wordpress - WordPress Settings and Configuration
Consider this code snippet:
add_option('theme_color', 'green');
update_option('theme_color', 'blue');
echo get_option('theme_color');

What will be printed?
Ablue
Bnull
Cgreen
Dtheme_color
Step-by-Step Solution
Solution:
  1. Step 1: add_option() sets 'theme_color' to 'green'

    This adds the option only if it does not exist.
  2. Step 2: update_option() changes 'theme_color' to 'blue'

    This updates the existing option value.
  3. Step 3: get_option() returns current value

    It returns 'blue' because update_option changed it.
  4. Final Answer:

    blue -> Option A
  5. Quick Check:

    update_option() overwrites add_option() value [OK]
Quick Trick: update_option() overwrites existing option values [OK]
Common Mistakes:
  • Thinking add_option() value stays after update_option()
  • Expecting get_option() to return null
  • Confusing option name with value

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Wordpress Quizzes