WordPress remove_action() Function

Beginner
6 min read
Updated: Nov 2026
3 examples
Action hook

Definition

In WordPress, remove_action() takes a function off an action hook. It undoes a previous add_action(), so the function no longer runs.

You can use it to turn off something that WordPress core, your parent theme, or a plugin added. To remove a function, you must give the same hook name, the same callback, and the same priority that were used to add it.

Syntax

Use the same values you used in add_action().

WordPress
<?php remove_action( 'wp_head', 'wp_generator' ); ?>
CallWhat it does
remove_action( 'wp_head', 'wp_generator' )Remove the WordPress version tag from the head.
remove_action( 'wp_footer', 'my_note', 20 )Remove a function that was added with priority 20.
remove_action( 'init', array( $obj, 'run' ) )Remove a method of a class object.

Call remove_action() after the function was added. It does nothing if the function is not found.

Full declaration
WordPress
remove_action( string $hook_name, callable|string|array $callback, int $priority = 10 ): bool

Parameters

ParameterDescription
$hook_namestring. The action hook the function is attached to.
$callbackcallable. The function to remove. For a class method, use the same array that was used to add it, such as array( $object, 'method' ).
$priorityint. The priority used when it was added. Default is 10. It must match exactly, or the function stays.

Return Value

Return ValueDescription
booltrue if the function was found and removed. false if nothing matched.

WordPress Examples

Three short examples. Each one shows the code and what it prints or does.

Example 1 — Remove the WordPress version tag

WordPress adds a generator tag to the head. Remove it with one line.

WordPress
remove_action( 'wp_head', 'wp_generator' );

How It Works

  1. WordPress core runs add_action( 'wp_head', 'wp_generator' ) with the default priority 10.
  2. remove_action() uses the same hook, callback, and priority, so it matches.
  3. The generator tag is removed from the page head.

Example 2 — Match the priority

Remove only works when the priority is the same. Check the return value to see what happened.

WordPress
function ctf_footer_note() {
  echo '<p>Thanks for visiting!</p>';
}
add_action( 'wp_footer', 'ctf_footer_note', 20 );

$wrong = remove_action( 'wp_footer', 'ctf_footer_note' );
$right = remove_action( 'wp_footer', 'ctf_footer_note', 20 );

echo 'Wrong priority: ' . ( $wrong ? 'true' : 'false' ) . "\n";
echo 'Right priority: ' . ( $right ? 'true' : 'false' );

How It Works

  1. The function was added with priority 20.
  2. The first call uses the default 10, so nothing matches and it returns false.
  3. The second call uses 20, so the function is removed and it returns true.

Example 3 — Remove a class method

For a method inside a class, pass the same object and method name in an array.

WordPress
class CTF_Banner {
  public function __construct() {
    add_action( 'wp_footer', array( $this, 'show_banner' ) );
  }
  public function show_banner() {
    echo '<div class="banner">Sale today!</div>';
  }
}
$ctf_banner = new CTF_Banner();

$removed = remove_action( 'wp_footer', array( $ctf_banner, 'show_banner' ) );
echo $removed ? 'Removed: true' : 'Removed: false';

How It Works

  1. The class adds show_banner with array( $this, 'show_banner' ).
  2. remove_action() needs the same object and method name, so we use $ctf_banner.
  3. If you do not have access to the object, you cannot remove the method this way.

Frequently Asked Questions

It removes a function that was added to an action hook with add_action(), so it no longer runs.
Nothing matched. The most common reasons are a different priority, a different callback, or the function was not added yet.
Call it after the function was added. For plugin code, use a later hook such as init or after_setup_theme. For core code, functions.php is usually fine.
It is very hard, because you need the same closure object. Use named functions when you may want to remove them later.
They work the same way. remove_action() is for action hooks and remove_filter() is for filter hooks.

Next: remove_filter()

Unhook a function that was added with add_filter().

remove_filter() tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

11 people found this page helpful