Bird
0
0

Why does this code produce an error?

medium📝 Debug Q7 of 15
Wordpress - WordPress Hooks System
Why does this code produce an error?
add_filter('the_excerpt', 'modify_excerpt');
function modify_excerpt($excerpt) {
return strtolower($excerpt);
}
echo apply_filters('the_excerpt');
Aapply_filters is called without the required second argument
BThe function 'modify_excerpt' is not defined
Cadd_filter cannot be used with 'the_excerpt'
DThe callback function must echo, not return a value
Step-by-Step Solution
Solution:
  1. Step 1: Check apply_filters usage

    apply_filters requires the value to filter as the second argument.
  2. Step 2: Identify missing argument

    Here, apply_filters('the_excerpt') lacks the value to filter.
  3. Final Answer:

    apply_filters is called without the required second argument -> Option A
  4. Quick Check:

    apply_filters needs a value argument [OK]
Quick Trick: apply_filters must have a value argument [OK]
Common Mistakes:
  • Omitting the value parameter in apply_filters
  • Confusing add_filter with add_action

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Wordpress Quizzes