[How to] Add AdSense Ads to WordPress Blog Without Any Plugin – Part 2

[How to] Add AdSense Ads to WordPress Blog Without Any Plugin – Part 2

You can edit the theme either in your WordPress admin panel or you can edit it in your favorite text editor and upload it later. I’m going to edit in WordPress theme editor.

Step1:

Login to your WordPress blog admin panel and then go to presentation>Theme editor

If   you don’t have the theme editor option it means that you are not allowed to modify the theme.

First we are going to place the ads in main page

Step 2:

In the theme editor open main index template

And look for <?php if (have_posts()) : ?> and add this line immediately after it <?php $count = 1 ?>

Now look for this line <?php endwhile; ?> and add <?php $count = $count+1; ?> just before it. The count variable will keep track of the number of posts in the main page.

Step 3:

Search for this line in the main index template

<?php the_content(‘Read the rest of this entry &raquo;’); ?>

This line displays the content of your post.

Paste these lines before or after that line

<br>

<?php if ($count==1) { include(‘horilinked.php’); } ?>

<?php if ($count==3) { include(‘bigrectangle.php’); } ?>

<?php if ($count==5) { include(‘bigreactangle_referral.php’); }?>

The above lines will ad a horizontal linked unit, bigreactangle, biggrecatangle referral after the title of your post ( If you place these lines before <?php the_content(‘Read the rest of this entry &raquo;’); ?>)

Step 4:

Now update the file and open single post

Look for this line <?php the_content(‘Read the rest of this entry &raquo;’); ?> and place

<?php { include(‘horilinked.php’); } ?> before it and  <?php { include(‘bigreactangle.php’); } ?> after it.

This will display horizontal linked unit after the post title and big rectangle at the end of the post.

Step 5:

If you want to display the ads in archives and search results page follow the steps followed for the main page.

To display ads in your sidebar just paste the adsense code in your text widget

To display ads in the middle of a post use adman plugin.

Note: Make sure that you don’t have more than 3 linked units,3 ad units and 4 referral units.

2 thoughts on “[How to] Add AdSense Ads to WordPress Blog Without Any Plugin – Part 2”

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.