0

Have you ever wondered how to show Google ads on your WordPress blog’s home page, but only after the very first article? Well, here is how you do it. And don’t worry, it’s quite simple, and you can’t permanently damage anything by giving it a try. ANYONE can do this!

  1. In the PRESENTATION menu, under THEMES EDITOR, find the theme file called “Main Index Template” (index.php).
  2. FIRST: Copy and paste everything you see here into a blank text file and save it. This way if you screw something up you can revert back to the original without hurting anything.
  3. Find a line of code that looks much like the following: <?php the_content('Read the rest of this entry »'); ?>
  4. Immediately after that, paste the following: <?php if ($count == 0) : ?> ENTER YOUR AD CODE HERE <?php endif; $count++; ?>
  5. Save the document and refresh your page. You should see the ad ONLY after the first article on the homepage.


So as an example, here is what the code might look like when installed (the red part is the new part):

<div class=”Post”>
      <div class=”PostHead”>
           <h1 class=”title”><?php the_title(); ?></h1>
           <p class=”PostInfo”>Posted on <?php the_time(’M d, Y – g:ia’); ?> <?php comment_time() ?> by <?php the_author() ?> in <?php the_category(’, ‘) ?></p>
      </div>
      <div class=”PostContent”>
           <?php the_content(’Read the rest of this entry »’); ?>
      </div>
</div>
<?php if ($count == 0) : ?>
<div class=”frontpage-google-ad” style=”border: dashed 1px black; padding: 10px” align=”center”>
      <script type=”text/javascript”><!–
      google_ad_client = “pub-0617773482327857″;
      google_ad_width = 468;
      google_ad_height = 60;
      google_ad_format = “468×60_as”;
      google_ad_type = “text_image”;
      //–>
      </script>
      <script type=”text/javascript” src=”http://pagead2.googlesyndication.com/pagead/show_ads.js”></script>
</div>
<?php endif; $count++; ?>

If it doesn’t show up in the right place, just try moving it around a bit and use a little trial and error. Also, remember to disable WP-Cache while you are testing the changes. If your pages are cached you won’t see the changes and it might throw you off a bit. You can enable it after you are satisfied.

DeliciousStumbleUponDiggTwitterMixxTechnoratiFacebookNews VineRedditLinkedInYahoo! BookmarksSphinn It!Hyves
Tags: , , ,

Related posts

  1. Customize the Wordpress Login Screen in 10 StepsTo my normal readers… sorry, but this post is not for you. I’ve been asked technical questions by several people...
  2. Robyn Tippins “How to Video Blog” TutorialFor those of you that run your own Blogs and who would like to one day create your own videos...
  3. Ford Model’s Workout Tips and RoutinesAs we all know, working out can be pretty boring. As we also know, often models are not the sharpest...
  4. Wordpress: Secure & Accessible PHP Contact Form SPAMs BlogsI am exceedingly pleased to announce that the one and only issue with the Secure & Accessible plugin has been...
  5. How to Invite ALL Facebook Friends to a Group, Event or PageI set up a couple of groups on Facebook and wanted to invite all my friends, but it would have...
  6. Stephen Colbert is Gonna LOVE this Kid!Hey, did you hear about the 5 year old kid who killed a 400 pound bear? Well, now you have…...
  7. Tutorial: How To Put Ads on WordPress Home Page OnlyFolks, since my site has gotten fairly popular I have people who want to advertise on the home page. The...