WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to remove the action hooks added by SEO ultimate plugin for some pages. The way it is added in the plugin's class is

    //Hook to output all <head> code i changed the priority to 2
    add_action('wp_head', array(&$this, 'template_head'), 2);

The SEO plugin creates a global variable like this

global $seo_ultimate;
    $seo_ultimate =& new SEO_Ultimate(__FILE__);

In my plugin, i try removing it by

add_action('wp_head',array($this, 'remove_seo_header'),1);

    function remove_seo_header() {

         remove_action('wp_head', array($seo_ultimate,'template_head'));

But it does not remove the action. Can anyone point out where am I wrong?

share|improve this question
up vote 1 down vote accepted

You have to use the same priority, and you need access to the global variable:

function remove_seo_header() {

        array( $GLOBALS['seo_ultimate'], 'template_head' ), 2 
share|improve this answer

You can also foreach through the registered hooks like this:

function remove_filter_in_class( $tag, $function_to_remove, $priority, $class ) {
    if ( isset( $GLOBALS['wp_filter'][ $tag ][ $priority ] ) ) {
        foreach ( $GLOBALS['wp_filter'][ $tag ][ $priority ] as $key => $function ) {
            if ( is_array( $function['function'] )
                && $function_to_remove === array_pop( $function['function'] )
                && $class === get_class( array_pop( $function['function'] ) )
            ) {
                return remove_filter( $tag, $key, $priority );

Source: https://gist.github.com/lgedeon/7806513f47b6466fc2cb

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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