remove_action in a theme

I’m using a theme that gets updated pretty frequently. For this, it has added a custom.php file to include modifications. Now, in this theme, under the functions.php, the developer has included his own meta section which is added using the following function:

add_action('wp_head', 'theme_metas');

I want to let my SEO plugin manage this, so I tried adding this into the custom.php:

remove_action('wp_head', 'theme_metas', 15);

I even tried altering the priority higher and lower than 10 (which is default) but the metas are still showing. Can someone shed some light please?

2 s
2

Your remove_action has to have a priority matching the priority used in add_action.

Important: To remove a hook, the $function_to_remove and $priority
arguments must match when the hook was added. This goes for both
filters and actions. No warning will be given on removal failure.

http://codex.wordpress.org/Function_Reference/remove_action

In you case, it looks like remove_action('wp_head', 'theme_metas'); should work, but you may be having trouble because of how and when your custom.php file loads.

Leave a Comment