05 August 2010

Show Adsense/other Ads Only on Home page or Post pages of Blogger/ WordPress blog

Advertisements

When you place ads to your Blogger or WordPress blog they appear on Home page, Post Pages and other pages. Some of you want to show the ads only on Home page or Posts pages. I already have a post related to it. But here is the simpler procedure you will like.

Show Adsense/other Ads Only on Home page or Post pages of Blogger blog

Show ads on Home Page only

Change your ad code as follows

<b:if cond='data:blog.pageType != &quot;item&quot;'> YOUR AD CODE </b:if>


Show ads on Individual Posts Page only

Change your ad code as follows

<b:if cond='data:blog.pageType == &quot;item&quot;'> YOUR AD CODE </b:if>

Show Adsense/other Ads Only on Home page or Post pages of WordPress blog

Show ads on Home Page only

Change your ad code as follows

<?php if (is_home()) { ?>
YOUR AD CODE
<?php } ?>


Show ads on Individual Posts Page only

Change your ad code as follows

<?php if (is_single()) { ?>
YOUR AD CODE
<?php } ?>

Related Posts

4 comments

September 15, 2010 at 12:46 AM

@drraman we have to use parsed code or the original code generated by adsense.

Thanks

September 15, 2010 at 7:02 AM

If you are adding ads directly to the template then it needs phrasing. If you add using Add a Gadget then it not needs phrasing.

December 20, 2011 at 11:41 PM

I'm using adsense within my posts. (ads look blended in with the post content) .
The ads are shown in top left corner with the post, top right corner of the post content.
My problem is, when i go to the blog's homepage. Post ads are also shown there (only the ads above !--more-- tag). since google doesn't allow more than 3 content ads per page, we can't allow this.

So i want to show these ads only in post pages but need to hide those in the home page.

I've tried using

< ?php if (!is_home()) : ?>
--- adsense code goes here ---


but the post now shows

< ?php if (!is_home()) : ?>



tags before showing the content. This means this php tags doesn't work.
I'm NOT using a static page for the homepage. homepage is a combination of the latest posts.

see http://www.verilog.asia

Thanks

December 21, 2011 at 12:24 AM

remove it and try following

<?php if(is_single() && $post==$posts[0] && !is_paged()) { ?>
Put Your Ads code here
<?php } ?>

Post a Comment

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More