PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Where do you add Hooks and Filters?

  1. I realize that this is a very basic question, but I feel like the Developer Documentation is missing the obvious - where do I place hook and/or Filter code? I can see a definition of the syntax but no direction as to what file it need to go into, if it is in the functions.php whether the <?php and ?> tags should be removed, etc. I've searched and searched through the forums to see some references, but there isn't clear direction.

    So where do I put Hooks and where do I put Filters?

    Posted 11 years ago on Tuesday October 9, 2012 | Permalink
  2. Since the hooks and filters are typically PHP code, they need to be included in a PHP block in your functions.php. If you are already inside a PHP block (which was opened with a <?php) then you can remove the beginning <?php and closing ?> from the example code you are pasting from our documentation. If you paste your code after a closed ?> you will need to start your filter or hook code and function with at <?php.

    If you let us know what you're trying to do, and paste your complete functions.php at pastie.org or pastebin.com we can help you with the placement.

    Posted 11 years ago on Wednesday October 10, 2012 | Permalink