Recall & Review
beginner
What is an action hook in WordPress?
An action hook is a way to add or change functionality in WordPress by running custom code at specific points during WordPress execution.
Click to reveal answer
beginner
How do you add a function to an action hook in WordPress?
Use the
add_action('hook_name', 'your_function_name'); function to tell WordPress to run your function when the hook runs.Click to reveal answer
intermediate
What is the difference between an action hook and a filter hook?
An action hook runs code at certain points but does not change data. A filter hook lets you modify data before it is used or displayed.
Click to reveal answer
intermediate
What parameters can
add_action accept besides the hook name and function?It can accept priority (number to control order) and number of accepted arguments (how many inputs your function expects).
Click to reveal answer
beginner
Give an example of a common WordPress action hook and its use.
The
wp_footer action hook runs just before the closing </body> tag. You can use it to add scripts or HTML to the footer.Click to reveal answer
Which function is used to attach a function to an action hook in WordPress?
✗ Incorrect
add_action attaches your function to an action hook. add_filter is for filters, do_action runs the hook, and apply_filters runs filters.
What does the priority parameter in
add_action control?✗ Incorrect
Priority controls the order functions run on the same hook. Lower numbers run first.
When is an action hook typically executed?
✗ Incorrect
Action hooks run at many points in WordPress, like loading the header, footer, or saving a post.
Which hook would you use to add code just before the closing
</body> tag?✗ Incorrect
wp_footer runs before the closing </body> tag, perfect for footer scripts.
What happens if you call
do_action('my_hook') in your code?✗ Incorrect
do_action runs all functions attached to the named action hook.
Explain what an action hook is and how you use it in WordPress.
Think about how WordPress lets you add your code at certain points.
You got /3 concepts.
Describe the difference between action hooks and filter hooks in WordPress.
One changes behavior, the other changes data.
You got /3 concepts.