How To Put AdSense Ads After A Single Post per Page
Posted by Joe Hauckes
If you're new here,
You may want to Subscribe to my RSS Feed or if you prefer ... Subscribe via e-mail. Thanks for visiting!
Do use AdSense on your Blog? Do you want to put some Ads after your posts but are limited by the fact that you can only have 3 instances of AdSense per page? Do you want to know how to show AdSense Ads after a certain post and not others to be sure you stay within Googles guidelines and not be banned?
Here’s how you can set up an AdSense campaign to show after one post per page. The example has the Ads showing after the second post, but you can set it up after any post number you like. And this also works on Category and “Next” pages without any other changes being made to your code.
Go to your index.php in the Presentation folder of your WordPress Dashboard.
And look for:
<?php if (have_posts()) :?>
<?php $postCount=0; ?>
<?php while (have_posts()) : the_post();?>
And IMMEDIATELY BEFORE it put this bit of code:
<?php
$postnum = 1;
$showadsense1 = 2;
?>
Go a little further down in the code and look for this (at the end of the content statement)
<?php endwhile; ?>
And place this bit of code RIGHT BEFORE that statement:
<?php
if ($postnum == $showadsense1)
(your AdSense code goes here)
$postnum++;
?>
It’s as simple as that. There should be no need to make any changes if and when you update your WordPress version, but you will have to remember to redo the code if you change your Theme.
You should be able to copy/paste the above code with no problems, just remember to put YOUR AdSense code in place of “(your AdSense code goes here)” or it will never work.
Questions or problems can be left in comments and I will answer them there so others will know the answer to your question too.
Related Posts:Answers to a Readers Question About SEO
Posted by Joe Hauckes
The other day, I asked everyone What Do YOU Want to Know? Brooke from Snippets n Blurbs asked a couple of questions (I hope I answered the first one in comments Brooke).
The question, which is the subject of this post was:
“This might not be what you want posted here - but I think that people need to know more about SEO - the general stuff. Why it is important, some of the costs associated, not all web designers offer that…etc.”
In order to answer these questions within a question, I will break it down a little bit.
- SEO is an acronym for Search Engine Optimization. In other words, it is how people can best find your site when using Google, Yahoo, MSN or any of the other Search Engines by typing in certain search terms or “Keywords”.
- Cost is not an object. It is free if you think you know how people will try to find the services, articles or products you offer. A suggestion I would make is to try to find your site on SE’s by using different terms to see what you get. Again, it’s free.
- The unasked question is How to go about it. This is where the Meta Tags come in. They are located in the “head” php in the presentation portion of your template.
Most templates will include a Meta Description which is derived from your “tagline”. An example of this would be:
<meta name=”description” content=”<?php bloginfo(’description’); ?>” />
<meta name=”author” content=”Joe Hauckes / My Computer Back in Service - http://mcbsconsulting.com” />
(you can add your own description in place of the bloginfo, but don’t make it too long)
The other is the Meta Keyword which is where you put words and phrases you think people will use to find you. Another example from MCBS:
<meta name=”keyword”
content=”help,DSL,Setup,php,online,offline,adapt,programs,install,hardware,software,
computer,consulting,internet,” />
Probably the most important is not within tags, but using the right “Keywords” within your content. If you write good content with a good mix of what you want people to find, they will come.
Just remember, none of this happens overnight, it takes time.
Related Posts:How to Insert Titles Instead of Previous/Next Links
Posted by Joe Hauckes

When your readers stop by on an individual post you probably would like them to read some of your other posts. But when they get to the end of your article the only thing they see is <- Previous or Next ->.
Why not give them an idea of what your “Previous post” is by adding the Title of the Article they would be reading?
First look in your Single Post php for your navigation class, it looks something like this:
<p class=”pagenav”><?php previous_post(’%',’« Earlier’, ‘no’); ?> | <?php next_post(’%',’Newer »’, ‘no’); ?> </p>
Using the same class designation (ie p class=”pagenav instead of div class=”navigation”) insert the following code:
<div class=”navigation”>
<span class=”alignleft”><?php next_posts_link(’& la quo ; ‘. __(’Earlier Entries’)) ?></span>
<span class=”alignright”><?php previous_posts_link(__(’Newer Entries’).’ & ra quo ;’) ?></span>
</div>
Save the code and go look at the navigation links at the bottom of a post, it should give you the Titles of the “previous” and “next” posts. You may have to make some minor adjustments to get the look you want, but it should work just fine. (Be sure to remember, there are no spaces in (& ra[la] quo ; )
If you don’t have a single post php, look for the navigation code in your Index php right after your content info.
Related Posts:Why Copy & Paste Doesn’t Work on Some Code
Posted by Joe Hauckes
In the post about Putting Post Preview Back the other day, I had an “*” for the Copy & Paste process to use the code I had shown. The reason being…
When you copy & paste code sometimes it doesn’t work.
This happens because sometimes you aren’t getting the “real” code. You are getting the “viewing” code instead of the actual characters that the computer reads.
As an example:
When the code calls for…
?>
<div id=’preview’ class=’wrap’>
so the computer knows where the “divider” is and what class the “preview” is and how it works, this is what the computer needs to run the code correctly.
But when you code it for viewing, it looks like this…
?& gt;
& lt;div id=’preview’ class=’wrap’& gt;
to the computer.
Does that sound confusing? Well, that’s what happens to the computer when it tries to read the “view” that we see instead of the “real”code that it needs. It gets confused.
So, the next time you Copy & Paste some code and it doesn’t work right the first time, try Typing the exact code you see in the text. The odds are that the code is right, but you are getting the “view” code instead of the “real” thing.
Related Posts:



