Stubborn Fanatic

Avatar

Documenting Tech Fanaticism


You're browsing: Home » adsense, blogger, my hacks » Blog article: Adsense inside your posts and only on post (item) pages

Adsense inside your posts and only on post (item) pages


Loui$$ from Blogging Secret just asked me how I was displaying adsense ads only on post (item) pages and inside the post i.e. in the beginning and the end of each post. For this I use the same if statements from my hack Display widgets only on pages you prefer but widget are not involved in this one as widgets cannot go inside a post.

First let me acknowledge the sources from which I learnt some essential adsense tricks for Blogger Beta:

1. Using adsense code in beta template by Loui$$.
2. Using adsense in posts by Deniz.

I recommend checking those out before proceeding with this hack. As always, please back-up your template before proceeding with this hack as you will be modifying some important portions of your template. Now for the hack. Simply look for:

<p><data:post.body/></p>

in your template’s <div class=’post’> section and replace it with the code given in code boxes below:
([Your Adsense] in the each of codes given below must be replaced with the adsense code of your choice)

1. This code:
(if you are not using any hacks like peek-a-boo posts, selective expandable posts or peek-a-boo on label, archive and search pages)

      <b:if cond='data:blog.pageType == "item"'>        <p><table align='center'><tr><td><center>[Your Adsense]</center></td></tr></table><data:post.body/><table align='center'><tr><td><center>[Your Adsense]</center></td></tr></table></p>      <b:else/><p><data:post.body/></p>      </b:if>

2. This code in bold-italic (If you are using Peek-a-boo posts hacks)
(If you are also using the peek-a-boo on label and search pages hack, then there may be some confusion regarding which <p><data:post.body/></p> must be replaced with the code given below. Therefore, I have included the peek-a-boo code as well so that you can easily locate the correct instance of data:post.body/ in your template.)

<div class='post-body' expr:id='"post-" + data:post.id'><b:if cond='data:blog.pageType == "item"'>        <p><table align='center'><tr><td><center>Your Adsense</center></td></tr></table><data:post.body/><table align='center'><tr><td><center>Your Adsense</center></td></tr></table></p><b:else/><style>#fullpost {display:none;}</style><p><data:post.body/></p><span id='showlink'><p><a expr:onclick='"javascript:showFull(\"post-" + data:post.id + "\");"' href='javascript:void(0);'>Continue reading...</a></p></span><span id='hidelink' style='display:none'><p><a expr:onclick='"javascript:hideFull(\"post-" + data:post.id + "\");"' href='javascript:void(0);'>Excerpts only...</a></p></span><script type='text/javascript'>checkFull(&quot;post-&quot; + &quot;<data:post.id/>&quot;)</script></b:if><div style='clear: both;'/> <!-- clear for photos floats --></div>

3. This code in bold-italic (If you are using selective expandable posts hack)

<div class='post-body' expr:id='"post-" + data:post.id'>

      <b:if cond='data:blog.pageType == "item"'>         <style>#fullpost{display:inline;}</style>   <p><table align='center'><tr><td><center>[Your Adsense]</center></td></tr></table><data:post.body/><br/><table align='center'><tr><td><center>[Your Adsense]</center></td></tr></table></p>

      <b:else/>         <style>#fullpost{display:none;}</style>

<p><data:post.body/></p>

        <span id='showlink'>         <a expr:href='data:post.url'>Read More......</a>        </span>        <script type='text/javascript'>          checkFull(&quot;post-&quot; + &quot;<data:post.id/>&quot;);        </script>      </b:if>      <div style='clear: both;'/> <!-- clear for photos floats -->    </div>

Hope this becomes the tipping point in your adsense revenues graph :D


No related posts.

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...
PDF version
  • thanks man it really worked for me :) visit my blog to check it out
    http://freewebdesigndepot.blogspot.com/
  • Kashif
    Hi Vivek,

    Excellent posts here by you . I have changed my template and applied post summaries hack to it and then tried to add this hack but it seems like Some other modifications have been already applied to the template which is not allowing adsense ads to appear . What to do in this case ??

    Here is the template I am talking about : RD
  • &quot;life.strikes&quot;
    http://happyschools.blogspot.com/<br />
    Thanks Vivek. Nice site and idea too.
  • desigal
    i can`t get it to work on my blog
    chek it plz and temme how to implement right side within posts ad


    TechnoKudi
  • Manish
    Hi! I have 5 post on my manin blogger page. I want to adsense only below one one main post (Not below all post) Pls tell me how can i do so.
  • Silkenhut
    I have read and applied the hack. It works perfectly! Thanks for sharing this info...

    lol at first I was shocked because I saw [Your Adsense] instead of the actual ad but I forgot I have not posted the adsense code yet. hehe

    Thanks once again. ^_^
  • Gopinath M
    Hi Vivek,
    When I tried implementing the same, the ads background and border are changed. Ads are displayed with in a black table and background color is random. If you have any idea regarding this problem, please let me know at gopinahtmunisifreddy@gmail.com. My blog is mgopinath.blogspot.com
  • SOCIETY FOR CONSERVATION OF AG
    hello vivek sanghi
    your blog is really a surprise gift to the new bloggerers. you heck adsense in your posts is really unbelievable item.
    keep it up

    with best wishes
    moneyindia123
  • hobbithob
    hi vivek...sat for an hour and finally figured that I put the code on the wrong place :-) great hack...keep it up.
  • hobbithob
    Hi Vivek

    Great post you have here. I have been trying to follow your hack as well the changing the Adsense code. However, it doesn't seem to work on my site. Could you please have a look? The site is http://indiapr.blogspot.com<br />
    best, HH
blog comments powered by Disqus