}
As a reminder, that goes in your child theme functions.php file (in between opening and closing php tags of course).
So that’s a walkthrough of an action hook, but how about a filter hook example?
We are going to keep things simple and use the ‘the_content’ filter hook. This hook allows you to modify the content before it is actually displayed in the web browser. So, if you wanted to customize all your posts with a message then you can do as follows:
1 | add_filter( 'the_content', 'pc_custom_content' ); |
This line informs WordPress we are up to something and intend to modify the content via the ‘pc_custom_content’ hook. Let’s define that hook callback function now:
123 | function pc_custom_content($content) { |