Hey there, fellow WordPress wrangler!
Ever wish you could sneak into the backstage of WordPress and whisper, “Hey, do this when that happens”? Well, you can — thanks to WordPress hooks.
Whether you’re building a personal site, crafting a client project, or just tinkering to learn — mastering hooks gives you superpowers.
In this post, we’re diving into:
✅ What the heck a WordPress hook actually is
✅ Two shiny tables: admin dashboard vs frontend hooks
✅ Key info: hook name, what it does, how many parameters it passes, and little pro tips
✅ Some cheeky commentary (because code is fun)
Let’s hook in!
So… What Is a WordPress Hook?
A WordPress hook is a way to tap into the core without hacking it.
Hooks come in two flavors:
- Action Hooks: Do something when WordPress gets to a certain point.
- Filter Hooks: Change something before it’s output or saved.
Think of them like event listeners or interceptors — but friendlier.
Now, WordPress is hooked up with hundreds of these. But instead of listing them all like a phonebook, I’ve split the most useful ones for personal developers into two tidy camps:
- 🛠️ Admin Dashboard Hooks (for the admin wizards)
- 🏡 Frontend Hooks (for what users actually see)
Grab your coffee ☕, it’s table time.
Frontend Hook Execution Order
Order | Hook Name | Type | Description | Parameters |
---|---|---|---|---|
1 | mu_plugin_loaded | Action | Fires once all must-use plugins are loaded. | None |
2 | network_plugin_loaded | Action | Fires once all network plugins are loaded. | None |
3 | muplugins_loaded | Action | All must-use plugins are connected. | None |
4 | registered_taxonomy | Action | Fires after a taxonomy is registered. | None |
5 | registered_post_type | Action | Fires after a post type is registered. | None |
6 | plugin_loaded | Action | Fires once a plugin is loaded. | None |
7 | plugins_loaded | Action | All plugins are plugged in. | None |
8 | sanitize_comment_cookies | Action | Sanitize comment cookies. | None |
9 | setup_theme | Action | Before loading the theme’s functions.php file. | None |
10 | load_textdomain | Action | Load the theme’s textdomain. | None |
11 | after_setup_theme | Action | After the theme’s functions.php file is loaded. | None |
12 | auth_cookie_malformed | Action | Fires when an authentication cookie is malformed. | None |
13 | auth_cookie_valid | Action | Fires when an authentication cookie is valid. | None |
14 | set_current_user | Action | Set the current user. | None |
15 | init | Action | Initialize WordPress. | None |
16 | widgets_init | Action | Initialize widgets. | None |
17 | register_sidebar | Action | Register sidebars. | None |
18 | wp_register_sidebar_widget | Action | Register sidebar widgets. | None |
19 | wp_default_scripts | Action | Register default scripts. | None |
20 | wp_default_styles | Action | Register default styles. | None |
21 | admin_bar_init | Action | Initialize the admin bar. | None |
22 | add_admin_bar_menus | Action | Add menus to the admin bar. | None |
23 | wp_loaded | Action | WordPress is fully loaded. | None |
24 | parse_request | Action | Parse the request. | None |
25 | send_headers | Action | Send HTTP headers. | None |
26 | parse_query | Action | Parse the query. | None |
27 | pre_get_posts | Filter | Modify the main query before it’s executed. | $query |
28 | posts_clauses | Filter | Modify the SQL clauses of the query. | $clauses, $query |
29 | posts_selection | Action | After the posts are selected. | None |
30 | wp | Action | WordPress environment is set up. | None |
31 | template_redirect | Action | Before the template is loaded. | None |
32 | get_header | Action | Before the header template is loaded. | None |
33 | wp_head | Action | Inside the <head> section of the theme. | None |
34 | wp_enqueue_scripts | Action | Enqueue scripts and styles for the front end. | None |
35 | wp_print_styles | Action | Print styles in the header. | None |
36 | wp_print_scripts | Action | Print scripts in the header. | None |
37 | get_search_form | Filter | Filter the search form HTML. | $form |
38 | loop_start | Action | Before the loop starts. | $query |
39 | the_post | Action | After each post is set up. | None |
40 | get_template_part_content | Action | Before a template part is loaded. | None |
41 | loop_end | Action | After the loop ends. | $query |
42 | get_sidebar | Action | Before the sidebar template is loaded. | None |
43 | dynamic_sidebar | Filter | Filter the sidebar’s widgets output. | $sidebar_output, $index |
44 | pre_get_comments | Filter | Modify the comments query before it’s executed. | $query |
45 | wp_meta | Action | Add meta tags to the header. | None |
46 | get_footer | Action | Before the footer template is loaded. | None |
47 | wp_footer | Action | Inside the footer section of the theme. | None |
48 | wp_print_footer_scripts | Action | Print scripts in the footer. | None |
49 | admin_bar_menu | Action | Modify the admin bar menu. | $wp_admin_bar |
50 | wp_before_admin_bar_render | Action | Before the admin bar is rendered. | None |
51 | wp_after_admin_bar_render | Action | After the admin bar is rendered. | None |
52 | shutdown | Action | After WordPress has finished processing. | None |
Admin Panel & AJAX Hook Execution Order
Order | Hook Name | Type | Description | Parameters |
---|---|---|---|---|
1 | mu_plugin_loaded | Action | Fires once all must-use plugins are loaded. | None |
2 | network_plugin_loaded | Action | Fires once all network plugins are loaded. | None |
3 | muplugins_loaded | Action | All must-use plugins are connected. | None |
4 | registered_taxonomy | Action | Fires after a taxonomy is registered. | None |
5 | registered_post_type | Action | Fires after a post type is registered. | None |
6 | plugin_loaded | Action | Fires once a plugin is loaded. | None |
7 | plugins_loaded | Action | All plugins are plugged in. | None |
8 | sanitize_comment_cookies | Action | Sanitize comment cookies. | None |
9 | setup_theme | Action | Before loading the theme’s functions.php file. | None |
10 | load_textdomain | Action | Load the theme’s textdomain. | None |
11 | after_setup_theme | Action | After the theme’s functions.php file is loaded. | None |
12 | auth_cookie_valid | Action | Fires when an authentication cookie is valid. | None |
13 | set_current_user | Action | Set the current user. | None |
14 | init | Action | Initialize WordPress. | None |
15 | widgets_init | Action | Initialize widgets. | None |
16 | register_sidebar | Action | Register sidebars. | None |
17 | wp_register_sidebar_widget | Action | Register sidebar widgets. | None |
18 | wp_default_scripts | Action | Register default scripts. | None |
19 | wp_default_styles | Action | Register default styles. | None |
20 | admin_bar_init | Action | Initialize the admin bar. | None |
21 | add_admin_bar_menus | Action | Add menus to the admin bar. | None |
22 | wp_loaded | Action | WordPress is fully loaded. | None |
23 | auth_redirect | Action | Redirects unauthenticated users to the login page. | None |
24 | _admin_menu | Action | Internal hook for setting up the admin menu. | None |
25 | admin_menu | Action | Allows adding items to the admin menu. | None |
26 | admin_init | Action | Initialize the admin panel. | None |
Quick Peek: Hook in Action
Let’s say you want to add a custom stylesheet only for the admin:
add_action('admin_enqueue_scripts', function() {
wp_enqueue_style('my-admin-style', get_template_directory_uri() . '/admin.css');
});
Or maybe, you’re sneaking a cheeky “Read More” after every post:
add_filter('the_content', function($content) {
if (is_single()) {
$content .= '<p>Thanks for reading! More coming soon.</p>';
}
return $content;
});
Wrapping It Up (With a Cherry on Top)
WordPress hooks might feel a bit invisible at first, but once you get them, you’ll start seeing the Matrix of WordPress.
They’re your way of bending WordPress to your will — without touching core files, breaking updates, or sacrificing kittens.
If you’re building your personal developer site, this is where your personality and code style shine. Want a slick dashboard experience for you and your clients? Use admin hooks. Want buttery frontend interactivity? Frontend hooks to the rescue!
What’s Next?
-> Try adding a few of these to your functions.php
-> Pick one unfamiliar hook and build something fun
-> Bookmark this post — trust me, future-you will thank you
Have a favorite hook not listed here? Or a custom use-case you’re proud of? Drop it in the comments. Let’s keep this hook party going!