Support » Fixing WordPress » remove_action problem when function is within class

  • Resolved Boris


    Hey there,

    this keeps driving me crazy. How come I can do this:
    add_action('wp_head', array( 'class_name', 'function_name' ) );

    but not this:
    remove_action('wp_head', array( 'class_name', 'function_name' ) );

    Since this doesn’t work (at least for me 🙂 what would I have to do then to remove an action that has been added through a class?

    Cheers for any help,

Viewing 3 replies - 1 through 3 (of 3 total)
  • Boris


    searched some more on the internet and it seems that the syntax is correct, but why… WHY doesn’t it work then?

    *very frustrated, very annoyed little sigh*

    Acyually, I’m trying this with 2.8-bleeding -edge and not with 2.7 as stated on the right (not that that’d make much difference I think)



    alright, found something that works.

    say we have a global called $var, then we can call remove_action like so:

    global $var;
    remove_action( 'wp_head', array( &$var, 'method_name' ) );

    and that & shouldn’t be encoded, must be the code…

    This helped me out trying to remove an action from SyntaxHighlighter Evolved. Thank you!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘remove_action problem when function is within class’ is closed to new replies.