Posted on Jul 09, 2007 - 1:20am by John P. in Tutorials, Wordpress
Folks, 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”.
By the way, I LOVE comments! Please feel free to leave one below!
Pages: « 1 [2] Show All
Thanks! You got me out of a jam!!