remove_all_actions( string $hook_name, int|false $priority = false ): true

Removes all of the callback functions from an action hook.

Parameters

$hook_namestringrequired
The action to remove callbacks from.
$priorityint|falseoptional
The priority number to remove them from.

Default:false

Return

true Always returns true.

More Information

Prior to Version 4.7

  • You can’t call this function from within the hook you would like to remove actions from. For example adding an action to wp_footer that calls remove_all_actions('wp_footer') will cause an infinite loop condition because the while loop suddenly doesn’t have a next value. In WordPress 3.8.1 you’ll get a warning message like:
    Warning: next() expects parameter 1 to be array, null given in wp-includes/plugin.php on line 431
  • You’ll just need to hook into a hook that’s called before the hook you wish to clear is called.

Since Version 4.7, these limitations have been addressed. Please refer to https://wordpress.org/support/wordpress-version/version-4-7/#for-developers

Source

function remove_all_actions( $hook_name, $priority = false ) {
	return remove_all_filters( $hook_name, $priority );
}

Changelog

VersionDescription
2.7.0Introduced.

User Contributed Notes

  1. Skip to note 4 content

    If you want only show the admin bar, you can use this:

    remove_all_actions( 'wp_head' );
    remove_all_actions( 'wp_footer' );
    
    // Add default wp_head actions
    add_action( 'wp_head', '_admin_bar_bump_cb', 0 );
    add_action( 'wp_head', 'wp_print_styles', 8 );
    add_action( 'wp_head', 'wp_print_head_scripts', 9 );
    
    // Add default wp_footer actions
    add_action( 'wp_footer', 'wp_admin_bar_render', 1000 );
    
    // Add admin bar initialization actions
    add_action( 'template_redirect', '_wp_admin_bar_init', 0 );
    add_action( 'admin_init', '_wp_admin_bar_init' );
    add_action( 'before_signup_header', '_wp_admin_bar_init' );
    add_action( 'activate_header', '_wp_admin_bar_init' );
    
    // Render admin bar in the footer and admin header
    add_action( 'wp_footer', 'wp_admin_bar_render', 1000 );
    add_action( 'in_admin_header', 'wp_admin_bar_render', 0 );

    And if you use the action wp, you can use get_query_var for custom templates or other things. Just like that:

    add_action( 'wp', function() {
        if ( get_query_var( 'my_var' ) ) {
            // code from above here
        }
    } );

You must log in before being able to contribute a note or feedback.