0
0
Wordpressframework~5 mins

Common action hooks in Wordpress - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is an action hook in WordPress?
An action hook is a way to add or change WordPress behavior by running custom code at specific points during WordPress execution.
Click to reveal answer
beginner
What does the wp_head action hook do?
The wp_head hook runs in the <head> section of a WordPress theme. It lets you add scripts, styles, or meta tags before the page loads.
Click to reveal answer
intermediate
When is the init action hook triggered?
The init hook runs after WordPress has loaded but before any headers are sent. It's used to initialize plugins, register post types, or start sessions.
Click to reveal answer
beginner
What is the purpose of the wp_footer action hook?
The wp_footer hook runs just before the closing </body> tag. It is used to add scripts or code that should load at the end of the page.
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') function. This tells WordPress to run your function when the hook runs.
Click to reveal answer
Which hook is best to add custom code inside the <head> section of a WordPress theme?
Aadmin_init
Bwp_head
Cwp_footer
Dinit
When does the init action hook run?
AAfter WordPress loads but before headers
BBefore WordPress loads
CAfter headers are sent
DAt the end of the page
Which hook is used to add code just before the closing </body> tag?
Ainit
Bwp_head
Cwp_footer
Dtemplate_redirect
How do you attach your function to a WordPress action hook?
Aadd_action('hook', 'function')
Badd_filter('hook', 'function')
Cdo_action('hook', 'function')
Dregister_hook('hook', 'function')
Which hook is NOT typically used for front-end page modifications?
Awp_head
Bwp_footer
Cinit
Dadmin_init
Explain what an action hook is in WordPress and give two examples of common action hooks used in themes.
Think about points in page load where you can add code.
You got /3 concepts.
    Describe how you would use the init action hook in a plugin.
    Init runs early, before headers.
    You got /3 concepts.