Bird
0
0

Why does this code fail to update the option?

medium📝 Debug Q7 of 15
Wordpress - WordPress Settings and Configuration
Why does this code fail to update the option?
add_option('font_size', '12px');
add_option('font_size', '14px');
Aadd_option() does not update existing options
BOption name must be unique each time
CSecond add_option() call overwrites first
DOption values must be integers
Step-by-Step Solution
Solution:
  1. Step 1: Understand add_option() behavior

    It adds a new option only if it does not exist.
  2. Step 2: Analyze second add_option() call

    Since 'font_size' exists, second call does nothing and does not update.
  3. Final Answer:

    add_option() does not update existing options -> Option A
  4. Quick Check:

    Use update_option() to change existing options [OK]
Quick Trick: add_option() only adds, does not update existing options [OK]
Common Mistakes:
  • Expecting add_option() to overwrite existing option
  • Thinking option names must be unique per call
  • Assuming values must be integers

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Wordpress Quizzes