Bird
0
0

Find the problem in this code:

medium📝 Debug Q7 of 15
Wordpress - WordPress Hooks System
Find the problem in this code:
add_action('wp_head', 'print_message');
function print_message() {
  echo 'Welcome!';
}
remove_action('wp_head', 'print_message');
AFunction print_message is not hooked correctly.
BHook name 'wp_head' is invalid.
Cremove_action is called immediately, so message never prints.
DEcho statement syntax is wrong.
Step-by-Step Solution
Solution:
  1. Step 1: Analyze the order of add_action and remove_action

    Since remove_action is called right after add_action, the function is removed before the hook runs.
  2. Step 2: Understand effect on output

    This means print_message will never run, so no output appears.
  3. Final Answer:

    remove_action is called immediately, so message never prints. -> Option C
  4. Quick Check:

    Immediate remove_action cancels hook [OK]
Quick Trick: Call remove_action only when you want to stop hooked functions [OK]
Common Mistakes:
  • Assuming remove_action runs after hook executes
  • Thinking function is not hooked
  • Misreading hook name validity

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Wordpress Quizzes