• Home
  • About John P.
  • Contact
  • Terms
  • Facebook
  • Google+
  • Instagram
  • LinkedIn
  • Pinterest
  • StumbleUpon
  • Twitter
  • YouTube

One Man's Blog

Specialization is for Insects.

  • 10 Best
  • Art
  • Computing
  • Fun Stuff
  • Gadgets
  • Videos
  • Photography
  • Travel
  • Tutorials
  • Health & Fitness
  • Politics
  • Thoughts
  • Food
  • Reviews
  • 10 Best
  • Art
  • Computing
  • Fun Stuff
  • Gadgets
  • Videos
  • Photography
  • Travel
  • Tutorials
  • Health & Fitness
  • Politics
  • Thoughts
  • Food
  • Reviews
Home / Tutorials / Tutorial: How To Put Ads on WordPress Home Page Only

Tutorial: How To Put Ads on WordPress Home Page Only

John P.

July 9, 2007 By John P.

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”.

Related

Filed Under: Tutorials, Wordpress Tagged With: Advertising, Rapid-Access, Tutorials, Wordpress

About John P.

John P. is a former CEO, former TV Show Host, and the Founder and Wizard behind Texas Metal Works. You can find him on Twitter, Facebook and LinkedIn. Feel free to send shoutouts, insults, and praise. Or Money. Money is good.

Comments

  1. DigiSecrets says

    May 9, 2013 at 10:16 pm

    Thanks for this tip mate… Now i am going to decorate my homepage with different stuffs :)

  2. Karenade says

    February 25, 2013 at 10:50 pm

    I’m grateful for sharing such a simple method of putting ads on homepage only.

  3. Sadek says

    January 18, 2013 at 1:04 pm

    I realized that this doesn’t work with Genesis framework, though it’s fine with other themes.

  4. engineer blogs says

    November 12, 2012 at 9:16 am

    it is easy to edit, thanks

  5. Rohit Roy says

    September 17, 2012 at 4:07 am

    Wow Awesome Tip
    Thanks John P

  6. Asepn says

    July 5, 2012 at 10:21 pm

    Thank you, I really appreciate it.

  7. Pete says

    January 8, 2011 at 8:17 pm

    Just been trying loads of different things that weren’t working, at last you had the solution and all good now! Thanks a lot

  8. Tim says

    December 17, 2010 at 9:00 am

    thanks, love it! Very helpful tutorial!

  9. asd says

    December 17, 2010 at 6:56 am

    thanks

  10. Peter Ahrens says

    November 26, 2010 at 8:53 am

    Thanks for that, you’re a life saver. This just saved me stuffing around trying to figure it out myself.

  11. edwin says

    July 30, 2010 at 1:39 am

    Thanks! This works if I want one link on the homepage only.

    What if I want a second and a third link? just below the first one. Home page only.

    Tried to modify the code but only the first link is showing. Any help would be greatly appreciated. Thanks again!

  12. PB says

    April 21, 2010 at 5:11 am

    How do you get this to show up just before the footer and below all of the posts on the front page? I can only seem to get it to work below the first post. Thanks.

  13. Mr. Ryan says

    April 3, 2010 at 10:23 am

    Thanks! I’ve looked for code snippits like this for years. Every now and then I get paid for homepage links but don’t know a way to show them just on the homepage. This is the first time your site has come up as the top result and I’m glad it did.

  14. Andy says

    August 9, 2009 at 12:19 am

    Thanks! You got me out of a jam!!

  15. Rosli says

    July 19, 2009 at 8:19 am

    Thanks a lot. Ii am a newbie who’s just starting out. I really appreciate the help in getting this done. Once again, Thank you very much.

  16. Bill says

    July 4, 2009 at 8:32 pm

    Thanks for posting the elegant code that allows you to only display particular content on the wordpress homepage. I was racking my brain all afternoon trying to figure out a way to do this, then I stumbled upon your site and it made my night! Thanks!

  17. Fred says

    June 19, 2009 at 5:35 pm

    Thanks for the help with the code. I have however some trouble with my requested advert as it needs to be incontent.

    for example: A
    anchor
    bit of blurb here

    The bit of blurb at the end is coming up fine, but I can’t seem to workout how to get the ‘A’ to appear before the link..

    Any help would be great..

    I have bookmarked your site, very helpful indeed, thanks

  18. Rana says

    January 29, 2009 at 9:51 pm

    It works like a charm, thanks for your tutorial.

  19. Dark orkut says

    January 21, 2009 at 7:23 am

    Thanks mate. It will help me to monetize my site well.

  20. Rob C says

    December 10, 2008 at 5:24 pm

    Ha! – the perfect solution to an issue I had with one of my sites! If only I’d thought to Google it earlier, instead of wasting my time *not* working out how to do it…

    Definitely linking you from my blog on the next update

    Thanks a lot!

  21. Michael Murdock says

    November 5, 2008 at 4:25 pm

    I loved this piece of code as I was able to drop it into a footer which is where I wanted the string of ads to show. This is great for companies that do a php string where they’re pulling from their server and dropping text into your page every time someone signs up for an ad. Wooohooo! Now ads only on the front page. Nice coding. Thanks for making it available.

  22. ika says

    November 4, 2008 at 9:47 pm

    thanks very very much!!! i googled about this by typing ‘ads on homepage only’ and your blog’s at the top! so thanks for posting about this code..

  23. andrew says

    August 18, 2008 at 7:46 pm

    Thanks for the code.
    Happy I can find your post on it.
    Really helpful.

  24. Johnny says

    May 21, 2008 at 5:29 pm

    Happy that I found this piece of code

  25. Shops says

    May 14, 2008 at 6:40 am

    I have a similar problem – Anyone know how to show the page number on the index page when you go prev next pages?

  26. Ronny Domain says

    May 3, 2008 at 9:57 pm

    When I need it for my new template, I found your post by googling with keyword ‘ only on homepage “wordpress” ‘
    That’s cool. It’s working at all. Thank you.

  27. John P. says

    March 14, 2008 at 7:05 pm

    Gio,

    Can you give me a little more specific information on exactly what happened and perhaps I can help you troubleshoot it?

    John

  28. John P. says

    February 25, 2008 at 5:58 pm

    Femikey,

    When you are in the admin control panel and select “Presentation”, you should see a tab that says “Theme Editor”. It is when you are within the theme editor that you can make the changes that I previously listed.

    In the theme editor find the index.php page and add the code whereever you want the ads to appear. You may have to experiment a bit to get it in just the spot you want it, so create a backup of the original code before you get to messing with things just to ensure you can revert back if necessary.

    John

  29. femikey says

    February 25, 2008 at 11:23 am

    hi i want to ask something about how to put ads at wordpress homepage only? because i have a wordpress blog but when i check the presentation i dont have index.php i only have themes, widgets, extras, custom image header and css stylesheet editor. How could i add the url that only shows to my homepage if i use the css stylesheet editor? I want to know this because there’s a company offer me to add their link on my link that shows only to my wordpress homepage and not with the other links for my post. Can you help me please? thanks..

    femikey

  30. nefesco says

    November 21, 2007 at 11:37 am

    WOW! Easy and effective! Thanks lot man ^_^

    P/S: Why do u have TWO *subscribe-to-comment* (top and below)? Izzit redundant? No offend, just askin if u might not have seen it… thx again for the wonderful tip :)

  31. John P. says

    September 14, 2007 at 3:56 pm

    Sorry Madel, it looks like you are using WordPress.com and I’m not sure how, or if, you can edit the themes there. This tip was really for the stand-alone WordPress that can be downloaded from WordPress.org.

    John

  32. John P. says

    September 14, 2007 at 3:54 pm

    Glad that helped you out Heris! :-)

  33. heris says

    September 14, 2007 at 12:15 pm

    Many many thanks for the tip. I have been looking for the answer on how to do it with Tigopedia Reloaded WP theme (it doesn’t separate page for homepage and category/archive), and your tip works very well.

  34. Brandon says

    September 13, 2007 at 5:25 pm

    To bad I don’t use adsense on most of my blogs :))

  35. Madel says

    September 13, 2007 at 2:46 pm

    Hi, I am wondering how can I go to the index.php to my theme, I realli want to put ads on my blog but can’t do it yet..help pls..

  36. dave says

    August 22, 2007 at 10:23 am

    Thanks for the code–I will certainly implement it on my blogs.

    Does anybody know of similar code that can be used for any/all php scripts, not just wordpress?

  37. Vishal says

    July 19, 2007 at 10:09 am

    Nice one. Will definitely plug it in my blog. Thx :-)

  38. johnnykarout says

    July 16, 2007 at 8:12 am

    Thank you a lot for this hint, I will start using it after I add this comment :)

  39. John P. says

    July 12, 2007 at 10:05 pm

    Storm,

    Thanks for the tip it worked perfectly! I’ve updated the article to reflect the change. I really appreciate it.

    John

  40. Storm says

    July 12, 2007 at 5:19 pm

    Of course if someone knows how to get them to ONLY appear on the root homepage I’d appreciate the tip.

    I was looking for just that, and found it here:

    http://www.douglaskarr.com/2006/09/06/wordpress-hack-after-the-first-post-only-on-the-home-page/

John P’s Tweets

Tweets by johnpoz

John P. on Instagram

Ok, what we're gonna do, see, is jack this bitch u Ok, what we're gonna do, see, is jack this bitch up so high you need a ladder to get in it. Then put low profile tires on it.

Makes sense.
Let them eat turkey... I mean cake. Let them eat turkey... I mean cake.
Need I say more? Need I say more?
Cleaned my vehicles with @ArmorAllUSA Ultra Shine Cleaned my vehicles with @ArmorAllUSA Ultra Shine Wash Wipes. Here's the story! http://onemansblog.com/ultrawipes

#ArmorAll - #Ad - #YeeHaw
Tomorrow I'm getting my new forklift from @quality Tomorrow I'm getting my new forklift from @quality_equipment! Can't wait to start forking stuff. ;-)
Aaarrgh! What should I choose? Aaarrgh! What should I choose?
Have I died and gone to heaven? Have I died and gone to heaven?
Hard boiled chili quail eggs anyone? Hard boiled chili quail eggs anyone?
I'll take two! I'll take two!
This exists. This exists.
Over two pounds of pizza! Over two pounds of pizza!
Where should I start? Where should I start?
Give it a minute. You'll get it... Give it a minute. You'll get it...
Instagram post 17855855425047701 Instagram post 17855855425047701
Instagram post 17849137462070109 Instagram post 17849137462070109
It'll tickle yore innards! It'll tickle yore innards!
Instagram post 17855388973056226 Instagram post 17855388973056226
The @genyhitch is a massive 80 pound drop hitch wi The @genyhitch is a massive 80 pound drop hitch with a bonus - it can absorb the shock from twists, turns and bumps in the road, providing cushioning for both the tow vehicle and whatever it's pulling.
Who's up for some ghost pepper powder in their sal Who's up for some ghost pepper powder in their salt?
Downloading at around 140 MB/S. That's a full Gig Downloading at around 140 MB/S.  That's a full Gigabit download speed from the World of Warcraft servers to the new @Acer Predator desktop machine.
Follow on Instagram

Read Over 2,500,000 Times

  • How I'd Hack Your Weak Passwords
  • Amusing Little Helicopter Game
  • A Compendium of 150 Monty Python Sketches
  • 10 Worst Drivers Ever Caught On Video
  • Get Your Virtual Haircut and Other Auditory Illusions
  • How Crack Cocaine is Made

Copyright © 2022 · Local Media on Genesis Framework · WordPress · Log in

Follow Along for E-Mail Updates
Don't miss any of John P's craziness! Just shove your email address in the slot below and we'll take care of the rest! :-)
Arrow

Email: