Truth, Computing and Fail

  • Home
  • About

Placing AdSense ads after the first post

anomit | March 11, 2007

Well, lets get to the point and admit that everybody wants to rake in some moolah from their AdSense susbscriptions. But the thing that bothers them the most would be the proper positioning of the ads. Imagine a new visitor coming to your blog to see it cluttered with misplaced ads, like one bang on top of the first post. Forget about clicking on the ad, he won’t even read your first post and there you have your potential $1 bidding you goodbye.

I got the idea of this trick from this post at Jake Jarvis’ blog. I had been on the lookout for such a thing for a long time.

In this post I will elaborate it a bit to make it easier for newbies at coding who may have difficulties finding out the start and end of loops.

The file you need to edit is index.php in most themes or like theloop.php in k2. Basically the idea is to put the ad block in the post loop. Remember that: the post loop.

Now open the required file in the Theme Editor from your wordpress admin and find the beginning of the post loop, the line containing if(have_posts()).

For example, in theloop.php you will find it in this manner:

if ( have_posts() ) {

Freshy makes life a bit easier for you, by including descriptions in the index.php file. Find out

<!--blog-->

Now that you have found this line, below this line declare a variable:

<?php $count = 1; ?>

Now go to the end of the post loop, to be understood by codes like

<?php endif; ?>

. After this line of code and just before the closure of the

</div>

tag, add this loop:

<?php if ($count == 1) : ?>

<!-- YOUR ADSENSE CODE HERE -->

<?php endif; $count++; ?>

Now placing the adsense code becomes easier if you are using the AdSense Deluxe plugin. It keeps the coding neat. Just put in the following line of code in the loop:

<?php adsense_deluxe_ads('Ad_Name'); ?>

and you are done!!

Categories
AdSense, Blog
Comments rss
Comments rss
Trackback
Trackback

« Blog makeover Street Hawk!! »

Leave a comment

You can use these tags : <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

What’s in

  • Examining the Linux VDSO
  • Symlinks in a libfs virtual file system: The Pains
  • Small rant on the FUSE API reference
  • Kernel module debugging: a simple technique
  • Vim/Cscope quickie

Blogroll

  • Akshay Kothari
  • Ankur Shrivastav (OS)
  • Ankur Sinha
  • Harsh J
  • Hullap
  • LUG manipal
  • Swap

Tags

aircrack airfail airtel assembly blues build c Coding college country cryptography dean faculty file systems fuckery gnuplot hacking India kernel linux mangalore manipal mpd music NASM plugin politicians pub culture python rant rock sam scheduler simulation SSFNet stupidity supernatural suppression syscall syscalls system calls unix vim xchat xml

Archives

  • April 2010
  • January 2010
  • December 2009
  • November 2009
  • October 2009
  • September 2009
  • July 2009
  • June 2009
  • May 2009
  • April 2009
  • March 2009
  • January 2009
  • November 2008
  • September 2008
  • August 2008
  • July 2008
  • June 2008
  • May 2008
  • April 2008
  • March 2008
  • February 2008
  • January 2008
  • October 2007
  • September 2007
  • July 2007
  • June 2007
  • May 2007
  • April 2007
  • March 2007

License

Creative Commons License
This work by Anomit Ghosh is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 2.5 India License.
rss Comments rss valid xhtml 1.1 design by jide powered by Wordpress get firefox