DISQUS

The Marketing Technology Blog: Wordpress Hack: After the First Post only on the Home Page

  • John Pozadzides · 2 years ago
    Douglas,

    I just wanted to drop you a quick thank you for this tip. I had written an article with a slightly different method that was less effective than yours and one of my readers pointed out your article to me.

    I have since modified my article and given credit where credit is due.

    Thanks again,

    John
  • Douglas Karr · 2 years ago
    Thanks John! As well, this was a nice reminder... I had removed the bLaugh a few layouts ago and never put it back. Until today!
  • kanute · 2 years ago
    You saved me alot of time, I was just about to start tweeking the loop when I saw this post, I'm really grateful. thanks for sharing it.
  • Tyler · 2 years ago
    Can I implement this code in the sidebar so that the ads only appear in the sidebar on the homepage?
    If not, can you please enlighten me on how I can do this?
    Thank you!
    Tyler
  • Stever · 2 years ago
    To get this code to work over in the sidebar, or anywhere outside of the while loop, just remove all the stuff about $post and $page from the code so you just have this;


    stuff goes here
  • Chris · 1 year ago
    Top stuff - thanks for sharing this, it's a very handy bit of code!
  • Cody McKibben · 1 year ago
    Holy cripe, Doug, you just saved my life. I've been looking for that if(is_home() && !is_paged()) solution for hours now! Thank you :)
  • Douglas Karr · 1 year ago
    You're welcome, Cody! That's why I put this stuff up there. :)
  • Vaibhav · 1 year ago
    Many thanks for this tip Douglas. Is there a way to add ads on specific pages instead of homepage? I every page has a pageId and we can identify the loaded page based on that..i am looking out for specific pointers.

    Thanks in advance
    Vaibhav
  • James · 10 months ago
    Really useful code, and I've been using it for a while. Is there a way to include an 'else' statement so that you can have ads that run on the homepage, and then others that run on every other page?

    I've been searching for ages and can't find it!

    Hope someone can help.

    Thanks in advance.

    James
  • Douglas Karr · 10 months ago
    Hi James,

    Sure! Rather than the close bracket, I think you can use:

    <? } elseif ($post==$posts[0] && !is_paged()) { ?>
    Your other html
    <? } ?>



    Doug
  • Armando Borge · 9 months ago
    Hello Douglas...

    I am working whit a plugin on my homepage... But the coderguidelines document has the restriction of don't touch the core theme code... so i am using the add_filter function...

    if(is_home()) add_filter('the_content','myfunction');

    But is doesn't work correctly.... this filter show me the pluging content in every post in my homepage... what can i do ? does exist another hook just for the content of the homepage ?

    Thanks...