WordPress.org

Support

Support » How-To and Troubleshooting » is_home() conditional tag for first page only

is_home() conditional tag for first page only

  • I wanna display a flash music player ONLY on the first page so when a person types in my address they will hear my music on the first page automatically playing.

    But the thing is my index page (homepage) has links to older posts so what happens is when the user clicks on “Older posts” on the home page it will go to a new page and then start the music again which can get pretty annoying if they go through lots of pages.

    Is there a condtion tag for the FIRST page of homepage?
    I tried <?php if (is_home('1')){ ?> but that didnt work

Viewing 15 replies - 1 through 15 (of 17 total)
  • The music is a very bad idea: don’t do it unless you want to chase away visitors…

    Conditional_Tags#A_Paged_Page

    The actuall site is a music site so i doubt having autoplaying music will put them off.

    The is_paged() condtion then shows the play on every older posts page including archives, searches and categories. I only want it to run on the FIRST page of only the HOMEPAGE.
    Isnt that possible?

    Well? is there any condition tag thats only for the first page of the homepage?

    is home AND is NOT paged

    So what do you mean by that?
    Will I have to take the older posts links off?

    Isnt there any other way? I wanna keep the older posts link but only have the player to load on the first homepage.

    What about getting it to link to LATEST archive pages instead?

    HairyLove
    Member

    @hairylove

    I would really like an answer to this question also.

    All my pages seem to be using conditional tags properly, except “Older Entries” pages are displaying “is_home” content. I need the “is_home” content on the FIRST HOME PAGE only!

    Please help us.

    HairyLove
    Member

    @hairylove

    Found it.

    Use this:

    if (is_home() && !is_paged())

    It excludes older pages.

    More here

    nicholas77
    Member

    @nicholas77

    HairyLove, I love you man! Exactly what I was looking for! Thanks!
    I’ve applied this to my website: http://www.freesoftwareworkshop.com

    wpceo
    Member

    @photozero

    <?php if(is_home() && !is_paged()):?>
    do something here.
    <?php endif;?>

    relaxedguy
    Member

    @relaxedguy

    I have tried all sorts of ways to display a block of text in my sidebar that only shows up on my blog home page, but my text shows up on all posts and pages. I am not using a special page for the home page of the blog, just the usual last 10 posts. Photozero, I tried your code, which is different from all the other solutions I’ve found, and that didn’t work either.

    I have the conditional code in a Text widget, could that be part of the problem?

    Justin Tadlock
    WordPress God

    @greenshady

    I have the conditional code in a Text widget, could that be part of the problem?

    Yes, that’s a problem. If you’re going to put PHP into a text widget, you need a plugin that’ll allow you to do that. Search for the Exec PHP plugin.

    relaxedguy
    Member

    @relaxedguy

    Yup, exe PHP plugin worked, forgot all about that. How silly you need a plugin, that needs to be fixed.

    Justin Tadlock
    WordPress God

    @greenshady

    How silly you need a plugin, that needs to be fixed.

    Not silly at all if new WP users input some crazy PHP that completely messes up their entire blogs. The forums here would be filled with even more questions like, “Help! I can’t see my dashboard!” Believe me, something like this would happen if PHP were allowed by default in the text widgets.

    WP was made to be extended through plugins. The default is a good thing. I’m fairly certain this is a security decision as well.

    It is called a Text widget, after all. 😉

    relaxedguy
    Member

    @relaxedguy

    Good point. The real issue in my mind is that we shouldn’t have to add PHP into the sidebar ourselves. Conditional data display like we’re talking about should be built into the Widget GUI. It’s pretty straightforward, now? Themes like Thesis are starting to allow this.

    Maybe thats it, the logic will go in the theme, not the WP core. Theme designers can come up with a shared library of functions that tie into the Widget pallet.

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘is_home() conditional tag for first page only’ is closed to new replies.