So whats the solution?
You’ll need to add the code in your themes templates files or better still, write a custom function which you can also use with conditional tags.
Lets take a look at some examples of code you can add to your child themes functions.php file to display banners, ads or pretty much anything else in different hook locations your Woo theme offers.
Display In WordPress Footer Based On Conditions
This code will work in any theme because it uses a WordPress hook and not a theme specific hook.
Change the conditional tag to whatever you like.
In the above example i’ve used a conditional tag for pages and added the page i.d of 100 which you will change to your own.
Execute Code In Any Theme Head Section
If you simply want to display content using the wp_head hook in WordPress, you can add this code to your child themes functions.php file.
This code will work with any theme.
You can change the WordPress hook wp_head to any other hook including theme specific hooks.
Woo Specific Hooks
This code will output your content after the posts content in a Woo theme only.
You can easily change the Woo ‘woo_post_after’ hook to another.
The below example will output your HTML before the posts content.
But Wait! There’s a Problem.
The code will also output on archives pages like you blog or homepage. So how do we fix that?
We add a conditional tag so it only displays on single posts and/or single pages. Not on archive pages.
Add Content After All Single Posts
This code displays after all posts on single posts only.
Add Content Before All Single Posts
This code displays before all page content on pages only including archive pages.
These are some examples which you can use in a Woo theme. The code snippets using the WordPress wp_head or wp_footer action hooks can be used in any theme.
Hook Reference Map
Here’s a complete list of Woo hooks displayed in a visual map.