0

Ads on WordPress HomepageFolks, since my site has gotten fairly popular I have people who want to advertise on the home page. The problem is that I didn’t know of a good method of embedding Ads that only show up on the home page and don’t appear site wide. (And not in the sidebar.)

I needed to employ a little PHP trickery in order to get this to work and I figured I’d share the methodology in case anyone else wanted to do this, or had a better idea as to how to pull it off.

In my case what I did was edit the Index.php file and added the following code to the bottom of the page inside the loop:
EDIT: Thanks to Storm for dropping me a comment with an even simpler method which came from Douglas Karr. Here it is:

<?php if(is_home() && $post==$posts[0] && !is_paged()) { ?>
     PLACE ADVERTISEMENT HERE.
<?php } ?>

What this does is causes the ads to appear on the Homepage, but not on any of the other Category or Archive “pages”.

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

Related posts

  1. Tutorial: Add 3 Centered Columns to Wordpress FooterThis post describes how to add variable width, centered columns of stuff to the Worpress footer. Not sure what I...
  2. Tutorial: Howto Increase the Number of Comments Visible in WordPress EditorFolks, I get a lot of comments here on One Man’s Blog (nearly 7,000 at this point). Often there are...
  3. WP Super Cache Speeds Up WordPress BlogsDonncha O’Caoimh, one of WordPress’ lead developers spent the last few weeks working on a brand new plugin called WP...
  4. 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...
  5. WordPress Custom Database Error PagesIf you’re running WordPress 2.3.2 or later, there is a new feature that allows you to to specify an error...
  6. Tutorial: How to Grow Marijuana at HomeOk. I swear you guys all must think I’m a drug addict or something because first I wrote an article...
  7. Wordpress Plugin: WP Admin Bar ReloadedWP Admin Bar is an indispensable Wordpress plugin which displays links to the Administration Panel at the top of a...