Read on and Subscribe! :)Now Reading ...

Insert Adsense in the Middle of Your Homepage Manually

By Ken Xu on Aug 30, 2007 in Blogging, Technical Skills

Note: This post is made especially for beginner in wordpress environment.

Have you ever seen some peoples are placing their ads in the middle / between their posts on the homepage but don’t have a clue on how to do that?

Then this short tutorial will help you insert Adsense on the Middle of your Homepage, Manually.

Although there is a plugin that will automatically set adsense to be appeared at your homepage, manual editing give you full control on how many ads that you are going to display.

This post was inspired by this image and how Engadget do this strategy on their megablog. (engadget insert adsense ads between the 3rd and 4th post and between 4th and 5th post):

optimize-ads-placement.jpg

This is Adsense’s recommended ads positioning. But it’s wise to not cluttering your blog with google ads if you are going to build credibility. Inserting only one between post is better than 3.

There is a study said that inserting 1 ads could be more profitable than 3 ads. Believe it or not, it’s your decision.

Below is my personal tutorial to insert google ads between post. If you happen to find problem after following this tutorial carefully, you can either commenting at this post or email me to ask for a help. :)

First thing first - preparation:

  1. Go to Google Adsense and log in to your account.
  2. Go to Adsense setup, and get your adsense code
  3. Open up your Notepad or Text editor application and paste the code.
  4. Save it with the name you like. And don’t close it yet.

Preparation - Stage Two:

  1. Open up your Wordpress panel (manual URL: http://yourblogname.what/wp-admin/)
  2. When the page has successfully load up, go to your presentation tab and then theme editor menu
  3. Find this file in the list (right column) and click it: Main Index Template (note: every theme should have this standard file name)
  4. Now you will have a pile of code that you should edit carefully.

Preparation - Stage Three:

  1. Download this zip file, extract it and edit it with notepad (file name: adsense_in_homepage.php)
  2. Paste your adsense code according to the instruction inside the file
  3. press CTRL+S to save it. (do not use ’save as…’ because it will change the file format)

Preparation - Final Stage:

  1. Open your FTP uploader application (recommended: CuteFTP)
  2. Upload adsense_in_homepage.php into your wordpress theme folder in your web host (standard location: wp-content/themes/[yourtheme]/ )
  3. After success uploading. Close the application and you have done preparing! :D

Now, let’s dive into the editing steps:

Start Editing:

  • Switch back to your Wordpress Admin Panel (The windows in Preparation - Stage two)
  • Don’t get fuzzy by the code ugly face. You just need to find and focus on this line of code:

<?php the_content (‘inside here will be vary for each template’); ?>

  • Hope this image will clear your cloudy mind :)

code.jpg

  • Move your cursor to the end of the </div> (the one below <?php the_content( ); ?> )
  • Press enter twice to make spaces
  • Now add this code to display google adsense ads between 2nd and 3nd of your post:

<?php if ($count==1) { include('adsense_in_homepage.php'); } ?>
<?php $count = $count + 1; ?>

  • the ($count==1) means the second space between your post. If you want to insert it between 4th and 5th post, change it to ($count==3).

What if you want to add another ads between other post?

Well, Specify the location and add this another line of code:

<?php if ($count==1) { include('adsense_in_homepage.php'); }?>
<?php if ($count==n) { include(’adsense_in_homepage.php’); }?>

<?php $count = $count + 1; ?>

Notice the n, Change it to the desire number. If your blog have 5 posts on the homepage, use this guide to insert the ads:

  • between 1st and 2nd: 0
  • between 2nd and 3rd: 1
  • between 3rd and 4th: 2
  • between 4th and 5th: 3
  • below 5th post: 4

Hope this post useful. Cheer!

Related Post

16 Excellent Responses for "Insert Adsense in the Middle of Your Homepage Manually"
  1. MyAvatars 0.2 keeyit Says:
    (August 30, 2007, 8:23 am)

    Cool.. But alot of steps to do it..
    Thanks.. I should try that…

    Reply to keeyit
    1. MyAvatars 0.2 Ken Xu Says:
      (August 30, 2007, 9:13 am)

      Hi, Keeyit. Thanks for commenting! :)
      Feel free to email me if you have some difficulty to install the code.

      Reply to Ken Xu
  2. MyAvatars 0.2 jamy Says:
    (August 30, 2007, 11:20 am)

    Ken,
    You read my mind. I was thinking about this.

    When I went to do this :
    # Download this file

    This come up :
    Paste your code there by removing this line of text first!

    Did you have the link of the download url right ?

    Reply to jamy
    1. MyAvatars 0.2 Ken Xu Says:
      (August 30, 2007, 12:26 pm)

      Oh, I was using PHP file just now. Well, I have switch to a zip (compressed) file to make download easier. :)

      Reply to Ken Xu
  3. MyAvatars 0.2 jamy Says:
    (August 30, 2007, 3:23 pm)

    Hi Ken,
    If it is not too much, can you write a post about using color.
    Eg. in this review post by RT Cunningham:
    http://www.untwistedvortex.com/2007/08/28/blog-review-seays-kopitiam/
    he gave a very constructive input on my blog theme being dull, eg. my posts’ headers.

    I would like to know how I insert color to my header, color to the wordings in my individual post.

    Thank you a million, you are the best !

    Jamy

    Reply to jamy
    1. MyAvatars 0.2 Ken Xu Says:
      (August 30, 2007, 10:47 pm)

      Hi, aunty. It’s all about the theme. May be you should change your theme to a colorful one? But I think that is not important. Design is just for first impression. You theme is neat enough and need no further change.

      But if you really need to change the theme color header or else, it’s located at the stylesheet/CSS file inside you theme folder. I will write about editing a CSS file later.

      But, to tell you frankly, every theme’s CSS file is different in their naming. So, it need some research before you can actually edit it.

      Reply to Ken Xu
  4. MyAvatars 0.2 jamy Says:
    (August 30, 2007, 10:19 pm)

    Ken,
    How about ads in the middle of the post ?
    Does that code works as well ?
    Jamy

    Reply to jamy
    1. MyAvatars 0.2 Ken Xu Says:
      (August 30, 2007, 10:49 pm)

      Oh, it’s different. This tips is for homepage only. If you want to insert google adsense ads inside your post, user ‘Adsense deluxe’ plugin instead of manual editing.

      Reply to Ken Xu
  5. MyAvatars 0.2 jamy Says:
    (August 31, 2007, 12:37 am)

    Ken,
    As always, thank you for your kindness to help.
    I will have a look at the CSS and see if I still remember how :):).
    Yes, I agree with you as well.
    Jamy

    Reply to jamy
  6. MyAvatars 0.2 pearl Says:
    (August 31, 2007, 12:45 am)

    as usual, another great post Ken :) stumbled it!!

    Reply to pearl
    1. MyAvatars 0.2 Ken Xu Says:
      (August 31, 2007, 1:29 am)

      Hi, Pearl! Thanks for the stumble, Pearl. It’s a great help!

      Reply to Ken Xu
  7. MyAvatars 0.2 jamy Says:
    (August 31, 2007, 1:16 am)

    Stumbled too
    :razz:

    Reply to jamy
    1. MyAvatars 0.2 Ken Xu Says:
      (August 31, 2007, 1:29 am)

      Thanks! :)

      Reply to Ken Xu
  8. MyAvatars 0.2 Lorne Williams Says:
    (December 8, 2007, 11:41 pm)

    I want to show you how to get a 100% conversion rate on your website traffic. This is not a sales pitch and there is nothing to buy. There is no squeeze page that is designed to sell you anything later either.

    This is an event that you should know about…

    First there was Pay Per Click advertising which pays you on the small percentage of website visitors that actually click on an advertisement. Now there is “Pay Per Play” advertising that will pay you on 100% of your website traffic… NO CLICKS NECESSARY!

    Pay Per Play caters to an audience that is larger than radio, television and print media combined. Billions of dollars are being spent by big brand advertisers and they are ready to pay you. Will you claim your share of the pie? Or will you let someone else have it?

    To learn more about Pay Per Play visit: http://f-r-ee.com/ppp

    Your future friend,
    Lorne Williams

    Reply to Lorne Williams
  9. MyAvatars 0.2 JennyHow Says:
    (January 16, 2008, 8:35 am)

    but there are no code in the php file, just 3 lines in the file:

    Paste your code here by removing this line of text first!

    that’s all?

    Reply to JennyHow
    1. MyAvatars 0.2 Ken Says:
      (January 16, 2008, 1:58 pm)

      Hi, Jen. Yes. Just Replace that text with your google code and follow the guide. Email me if you meet with something strange after apply my tips. Cheers!

      Reply to Ken

Leave a reply

:mrgreen: :| :twisted: :arrow: 8O :) :? 8) :evil: :D :idea: :oops: :P :roll: ;) :cry: :o :lol: :x :( :!: :?:

Live Preview:


Go ahead and start typing.

Comment Policy:
Please double check your comment before submitting. I reserved the right to delete any comments which containing spam, bold advertisement, verbal abusive, or any other form of comment that is not suitable for publication.

    Subscribe

  • Subscription Choices:
  • Subscribe to our Newsletter. Read the Benefits of subscribe here.
  • Your privacy is our priority.

    Recent Readers

    Get Firefox!

  • This Blog is optimized for Firefox.
  • Foxkeh