Greetings, I'm hoping someone can help me with a piece of code that I can wrap around an ad in my sidebar so that the ad shows on the homepage/index page only and not on post pages. Any help would be greatly appreciated. Thank you in advance for your time and efforts.
I managed to find a piece of code that works. I thought I would post it here in case anyone else needs a similar fix for their wordpress site: As for Adsense - best performing ad format is the 250x300, so consider using something like that, showing either at the top left or top right of your post. <?php if(is_home() && $post==$posts[0] && !is_paged()) { ?> Advertisement code goes here and is displayed on the homepage only <?php } ?>
Is there a code to place ads everywhere EXCEPT on the home page? This code is perfect but it leaves a gap on other pages where the ads were.
This is the perfect code: <?php if (is_home()) { ?> Advertisement code which is displayed on homepage only <?php } ?> Replace home with single to display ad on single page only. Cheers
Agreed, the above code works if you have to show the sidebar only on the homepage. But as per different requirements, I wanted to show sidebar on all pages but the homepage. I googled and found these two links which I found interesting (One) (Two)
<?php $homepage = "/"; $currentpage = $_SERVER['REQUEST_URI']; if($homepage==$currentpage) { echo 'Adcode here' ; } ?> This Will Work And I use this ~Exp~