Adding custom functionality to WordPress for business themes and plugins always involves working with action and filter hooks. This is WordPress’ event architecture, and it’s a core reason why it’s so extensible. The action hooks and filters changes from install to install, because most plugins provide a set of custom filters and hooks for developers to work with. I frequently use the following function within a custom theme or functionality plugin to provide a quick list of all action hooks and filters available on the current URL.

WordPress Hooks Reference: All Filter and Action Hooks in Order

WordPress Hooks Reference

Place this in your theme’s functions.php file or inside of a plugins source then visit a page in your site with ?wp-hooks added onto the end of the URL. To provide some basic security, you’ll also need to be logged in as an Administrator level user for the WordPress Hooks Reference to display.

The reference generated by this approach will show you:

  1. Every action and filter hook that is called
  2. Actions are ordered by execution
  3. Filters are alphabetically ordered
/**
* WordPress Hooks Reference
*
* Dump all action and filter hooks at the bottom of any page
* by adding ?wp-hooks onto the end of the URL while logged-in
* as an Administrator level user.
*/
function kevinlearynet_hooks_reference() {

    // Only shown for Administrator level users when ?list-wp-hooks is added to the URL
    $trigger = isset( $_GET['wp-hooks'] ) && current_user_can( 'manage_options' );
    if ( ! $trigger ) return;

    // Capture and sort filters and hooks
    $filters = array_keys( $GLOBALS['wp_filter'] );
    sort( $filters );
    $actions = array_keys( $GLOBALS['wp_actions'] );

    // Output rough template
    ob_start();
    ?>
    <section class="wp-hooks">
    <h1 class="wp-hooks__h1">WordPress Hooks Reference</h1>
    <div class="wp-hooks__lists">
    <div class="wp-hooks__col">
    <h2 class="wp-hooks__h2">Actions</h2>
    <?php foreach ( $actions as $hook ) : ?>
    <p class="wp-hooks__hook"><?php echo $hook; ?></p>
    <?php endforeach; ?>
    </div>
    <div class="wp-hooks__col">
    <h2 class="wp-hooks__h2">Filters</h2>
    <?php foreach ( $filters as $hook ) : ?>
    <p class="wp-hooks__hook"><?php echo $hook; ?></p>
    <?php endforeach; ?>
    </div>
    </div>
    </section>
    <style>
    .wp-hooks {
        padding: 30px;
        margin: 30px;
        border-radius: 4px;
        background: white;
        font-size: 16px;
        line-height: 1.4;
        height: 50vh;
        min-height: 500px;
        overflow-y: scroll;
    }
    .wp-hooks__lists {
        display: flex;
    }
    .wp-hooks__col {
        flex: 1;
        width: 50%;
    }
    .wp-hooks__h1 {
        margin: 0 0 20px;
    }
    .wp-hooks__h2 {
        line-height: 1;
        font-size: 18px;
        margin: 0 0 10px;
    }
    .wp-hooks__hook {
        padding: 0;
        margin: 0;
    }
    </style>
    <?php
    ob_end_flush();
}
add_action( 'shutdown', 'kevinlearynet_hooks_reference' );

Meet the Author

Kevin Leary, Boston WordPress Developer of 10 Years

I'm a freelance web developer and WordPress consultant in Boston, MA with 13 years of experience building websites and applications. View a portfolio of my work or request an estimate for your next project.