Bird
0
0

What will this code output?

medium📝 Predict Output Q4 of 15
Wordpress - WordPress Hooks System
What will this code output?
add_filter('the_content', function($content) { return $content . ' - Modified'; });
echo apply_filters('the_content', 'Hello World');
A - Modified
BHello World - Modified
CHello World
DError: undefined function
Step-by-Step Solution
Solution:
  1. Step 1: Understand what add_filter does here

    The anonymous function appends ' - Modified' to the content passed through 'the_content' filter.
  2. Step 2: Apply the filter to the string 'Hello World'

    apply_filters calls the filter, so 'Hello World' becomes 'Hello World - Modified'.
  3. Final Answer:

    Hello World - Modified -> Option B
  4. Quick Check:

    Filter modifies content = C [OK]
Quick Trick: Filters change data passed through apply_filters() [OK]
Common Mistakes:
  • Ignoring the filter function effect
  • Expecting original string without modification
  • Thinking apply_filters causes error

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Wordpress Quizzes