Community Forums › Forums › Archived Forums › Design Tips and Tricks › Need help with Conditional Tags
Tagged: conditional tags, genesis, Genesis Simple Hooks, parallax-pro
- This topic has 8 replies, 2 voices, and was last updated 8 years, 12 months ago by kavikalyn.
-
AuthorPosts
-
April 29, 2015 at 1:01 pm #149531kavikalynMember
Hello, I'm using Genesis with the Parallax Pro theme. I want to show a Google Adsense 728x90 banner ad at the top and the bottom of each page except the home page. I've got the homepage set up with the parallax blocks and it looks really bad with ads.
I'm using the Genesis Simple Hooks plugin to add the Adsense code to the genesis_before_loop and genesis_after_loop tags and the pages look great. I just need a way to not show the ads on the homepage.
I contacted Synthesis support and they said I needed to use conditional tags and sent me a link to this page: http://codex.wordpress.org/Conditional_Tags
I understand the idea behind how these work I'm just not sure how to exactly write the code. I basically need a bit of code to put in the Genesis hooks that says:
If it's the home page > Don't do anything
If it's not the home page (any other page on the site) > show Adsense code in this hookCan anyone help me out with this? I imagine it should be pretty simple.
Thanks in advance for any help.
April 29, 2015 at 2:30 pm #149538Brad DaltonParticipantAdd
if ( ! is_front_page())
Home page relates to your posts page so i assume you mean the front page otherwise use
! is_home()
Examples http://designsbynickthegeek.com/tutorials/conditional-page-content
April 29, 2015 at 4:23 pm #149549kavikalynMemberThat link was helpful, thanks. So is this right? I want to show the ads on every page except the home page (it's a specific page not my posts page).
if(is_singular()) { ?>
ADSENSE CODE
<?php }And in theory that would show on every single page except the home page and I just paste that code into the simple hooks plugin?
There's no way to do an "is not home page" is there?
April 29, 2015 at 4:26 pm #149550Brad DaltonParticipant! is_home()
Excludes the home page and displays on every other page including archives, pages and posts.
I wouldn't use the plugin. I would use code in the functions file like:
- add_action( 'genesis_before_loop', 'adsense' ); function adsense() { if ( !is_home() ) { echo'Your Script'; } }
Even better to create a widget
April 29, 2015 at 4:36 pm #149553Brad DaltonParticipantThis is the best way http://wpsites.net/web-design/widget-genesis/
April 29, 2015 at 5:25 pm #149556kavikalynMemberThanks for the help so far.
I tried adding the following to the function.php file:
add_action( 'genesis_before_loop', 'adsense' ); function adsense() { if ( !is_home() ) { echo'Your Script'; } }
And it showed the ads in the correct location but still showed them on the homepage.
I'm not very comfortable with the coding and with creating a widget area so I'd rather just use the simple hooks plugin.
I tried putting the following in the simple hooks plugin:
if(! is_home()) { ?> ADSENSE CODE <?php }
And that didn't work either.
April 29, 2015 at 5:42 pm #149557Brad DaltonParticipantLink to your home page please.
Did you try
if ( ! is_front_page())
If you only want it on single posts, use:
if ( is_singular('post') )
April 29, 2015 at 5:44 pm #149558kavikalynMemberI have a coming soon plugin but I disabled it for a bit so you can see the homepage.
Thanks.
April 30, 2015 at 3:06 pm #149662kavikalynMemberIs anyone else out there able to help?
I need to know what code for conditional tags to put around my Adsense code so ads will show on every page except the homepage.
I'm entering this code in genesis_before_loop and genesis_after_loop using the Genesis Simple Hooks plugin.
Thanks in advance for any help.
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.