Hooks Ref Frontend

Here’s a cheatsheet of WordPress frontend action hooks in the approximate order they fire during a typical page load. This will help you understand the execution flow and where to inject your custom code.


1. Before WordPress Initializes

These hooks fire very early, before most of WordPress is loaded.

  • muplugins_loaded – After must-use plugins are loaded.
  • registered_taxonomy – When a taxonomy is registered.
  • registered_post_type – When a post type is registered.
  • plugins_loaded – After active plugins are loaded.
  • setup_theme – Before the theme is loaded.
  • after_setup_theme – Immediately after the theme is loaded.
  • init – WordPress core is fully initialized (widgets, taxonomies, post types).
  • wp_loaded – WordPress is fully loaded (after init and plugins are ready).

2. Template Processing

Hooks related to template loading and content rendering.

  • template_redirect – Before WordPress decides which template to load.
  • wp_head – Inside the <head> section (called by wp_head()).
  • wp_body_open – Right after the opening <body> tag (called by wp_body_open()).
  • wp_enqueue_scripts – Proper place to enqueue scripts/styles (should hook here for frontend assets).

3. The Loop & Content Rendering

Hooks fired during the main query and content generation.

  • pre_get_posts – Before the main query runs (modify query vars).
  • the_post – For each post in the loop.
  • loop_start – Before the loop begins.
  • loop_end – After the loop ends.
  • wp_footer – Before closing </body> (called by wp_footer()).

4. Single Post/Page Specific

Hooks that fire when viewing a single post or page.

  • get_header – Before the header template loads.
  • get_footer – Before the footer template loads.
  • get_sidebar – Before the sidebar template loads.
  • the_content – Filters the post content (also applies to the_excerpt).

5. After Page Render

Hooks that fire at the very end.

  • shutdown – Very last hook before PHP shuts down (after page is sent to the browser).

Bonus: Conditional Hooks

These fire only in specific contexts:

  • wp_print_scripts – When scripts are printed (not recommended for enqueuing).
  • wp_print_styles – When styles are printed (not recommended for enqueuing).
  • comment_form_before – Before the comment form.
  • comment_form_after – After the comment form.
  • dynamic_sidebar_before – Before a dynamic sidebar.
  • dynamic_sidebar_after – After a dynamic sidebar.