Bird
0
0

Identify the error in this plugin code that tries to add a footer message:

medium📝 Debug Q14 of 15
Wordpress - Plugins and Extensibility
Identify the error in this plugin code that tries to add a footer message:
function add_footer_message() {
  echo 'Thank you for visiting!';
}
add_filter('wp_footer', 'add_footer_message');
AMissing semicolon after echo statement
BUsing add_filter instead of add_action for outputting content
CFunction name should be prefixed with 'wp_'
DThe hook name 'wp_footer' does not exist
Step-by-Step Solution
Solution:
  1. Step 1: Understand hook types

    add_filter is for modifying data, add_action is for outputting content like footer messages.
  2. Step 2: Check code syntax and hook name

    Echo statement has semicolon; 'wp_footer' is a valid action hook; function name prefix is optional.
  3. Final Answer:

    Using add_filter instead of add_action for outputting content -> Option B
  4. Quick Check:

    Use add_action to output HTML [OK]
Quick Trick: Use add_action to print content, add_filter to change data [OK]
Common Mistakes:
MISTAKES
  • Confusing add_filter and add_action
  • Thinking function names must start with 'wp_'
  • Believing hook name is invalid

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Wordpress Quizzes