Bird
0
0

Given this code in functions.php:

medium📝 component behavior Q13 of 15
Wordpress - Theme Structure and Basics
Given this code in functions.php:
function add_custom_text() {
  echo 'Hello, visitor!';
}
add_action('wp_footer', 'add_custom_text');
What will happen on the website?
ANothing will appear because the function is incorrect
BThe text will appear at the top of every page
CThe text 'Hello, visitor!' will appear in the footer of every page
DThe site will crash due to syntax error
Step-by-Step Solution
Solution:
  1. Step 1: Understand the add_action hook

    The code uses add_action('wp_footer', 'add_custom_text'); which runs the function at the footer of the site.
  2. Step 2: Analyze the function output

    The function add_custom_text() echoes 'Hello, visitor!', so this text will show in the footer area on every page.
  3. Final Answer:

    The text 'Hello, visitor!' will appear in the footer of every page -> Option C
  4. Quick Check:

    add_action('wp_footer') adds output to footer [OK]
Quick Trick: add_action('wp_footer') runs code in footer area [OK]
Common Mistakes:
MISTAKES
  • Thinking text appears at top instead of footer
  • Assuming function does nothing
  • Confusing echo with return

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Wordpress Quizzes