Archived topic
How to stop a hook from running on a certain page
4 replies · Started by Derek on June 6, 2018
Hello,
I have a before header hook that I don't want to run on my home page. How can I disable this for my home page?
Thank you!
Hi Derek, see the various conditional options here:
https://docs.generatepress.com/article/using-hooks-conditional-tags/
Ok so here one of the codes im working with:
<?php if ( ! is_front_page() ) : ?>
<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<script>
(adsbygoogle = window.adsbygoogle || []).push({
google_ad_client: "ca-pub-#########",
enable_page_level_ads: true
});
</script>
<?php endif; ?>
It's not working as is, I'm sure I missed something in how its formatted...I know zero about php so I just tried to follow the instructions. Suggestions?
Thanks.
False alarm it looks like its working, must have been a cache thing.
Glad to hear you got it resolved.