Archived topic
WP Hooks at Page Level
5 replies · Started by Vinai on September 20, 2017
Is it possible to have wp_hooks at a page level, so that we can insert the Google conversion code at the bottom of the page, just above the closing </body> tag?
I tried a couple of header/footer script inserting plug-ins, but they don't insert the script exactly above the </body>, but somewhere higher up...
Is there a neat solution to do this. Thanks.
Hi there,
Looks like you are looking for the wp_footer hook? https://docs.generatepress.com/article/wp_footer/?
Let me know.
yes, but I want the footer hook at each page level, not for the entire site.
Keep in mind, I am NOT installing Google Analytics code - which goes on EACH page.
I am installing Google CONVERSION code, which is a specific piece of code for specific pages. NOT ALL PAGES.
Can wp_footer do this? If not, what is the alternative? Thanks.
You'd have to use conditional tags in hooks. Something like this:
<?php if ( is_page( array( '1268', '6' ) ) ) :
code here
endif; ?>
See how to use conditional tags here: https://codex.wordpress.org/Conditional_Tags#A_PAGE_Page
ok got it. Thanks Leo.
No problem!