Bird
0
0

What will be the output of this code?

medium📝 Predict Output Q4 of 15
Wordpress - WordPress Hooks System
What will be the output of this code?
function say_hello() {
  echo 'Hello '; 
}
add_action('wp_footer', 'say_hello');
do_action('wp_footer');
Asay_hello
BHello
Cwp_footer
DNo output
Step-by-Step Solution
Solution:
  1. Step 1: Understand add_action and do_action

    The function say_hello is hooked to wp_footer and will run when do_action('wp_footer') is called.
  2. Step 2: Check the function output

    The function echoes 'Hello ', so this string will be printed.
  3. Final Answer:

    Hello -> Option B
  4. Quick Check:

    Hooked function output runs on do_action [OK]
Quick Trick: do_action runs hooked functions and shows their output [OK]
Common Mistakes:
  • Expecting function name as output
  • Confusing hook name with output
  • Thinking no output occurs without template

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Wordpress Quizzes