Issue with GP Hooks
-
Hi,
I want to add my ‘AdSense ad” in “before_the_main_content” GP Hook.
I referred your documentation and found this PHP code,
add_action( ‘your_hook_name’,’example_function_name’ );
function example_function_name() { ?>
Insert your hook contents in here.
<?php }But this adds the AdSense code on all pages including HOMEPAGE.
I referred your conditional hooks tags documentation,
https://docs.generatepress.com/article/using-hooks-conditional-tags/#blog-posts-pageBut the issue is, how will I combine
add_action( ‘your_hook_name’,’example_function_name’ );
function example_function_name() { ?>
Insert your hook contents in here.
<?php }AND
This<?php if ( ! is_front_page() ) : ?>
This content is EXCLUDED from the static front page
<?php endif; ?>I have no PHP coding knowledge
My “before_the_main_content” code will look something like this,
add_action( ‘your_hook_name’,’example_function_name’ );
function example_function_name() { ?>
<div align=”center”>
<ins class=”adsbygoogle”
style=”display:inline-block;width:xxpx;height:xxpx”
data-ad-client=”ca-pub-xxxxxxxxxxxx”
data-ad-slot=”xxxxxxxxxx”>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>
</div>
<?php }I DON’T want this to run on my HOMEPAGE.
Please help me with this.Thank You.
- The topic ‘Issue with GP Hooks’ is closed to new replies.