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?


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.


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.

  • It doesn't work. I have added other functions in the custom.php and they load just find. This is the only code that is not overriding the add_action function. Any other suggestion? Globally define it or something perhaps? Thanks a lot for your kind assistance nevertheless. Feb 15 '13 at 7:15
  • You were right! The custom.php was being called BEFORE the add_action which is why it was not overriding it. Thanks a lot sir. Feb 15 '13 at 7:46

For removing an action the priority has to be the same priority as was used when adding the action. in your case it should be

remove_action('wp_head', 'theme_metas');


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

The fine detail to remember is that remove of an action can be done only after the action was already added. Actions are simply stored in an array and all remove_action does is to nullify the entry. If remove_action is called before add_action the end result will be that the remove will effectively do nothing.

Therefor you should call remove_action only when you are sure that the add_action was called and for most actions a good bet is to hook with highest priority on the hook in question.

In your case

add_action('wp_head','wpse86994_remove_action',1); // prioroty of 1, but can be anything higher (lower number) then the priority of the action

function wpse86994_remove_action() {
  remove_action('wp_head', 'theme_metas');
  • None of them seems to work. How is priority considered? Is a lower integer considered higher priority or is it the other way round? Thanks a lot for your kind assistance nevertheless. Feb 15 '13 at 7:17
  • priority doesn't specify the priority of the remove but the priority of the action to be removed. Your problem might be that you are trying to remove the action before it was added, will update the answer for that Feb 15 '13 at 7:24
  • Thanks mark. That was helpful! I checked the functions source code and apparently the custom.php was being "require_once"-ed before the add_filter code which was causing that issue. I've reported it to the theme developer too. You were very helpful. Feb 15 '13 at 7:44
  • This was extremely helpful for me in understanding priority of an action.
    – Jake
    Mar 27 '19 at 1:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.