WordPress.org

Ready to get started?Download WordPress

Forums

is_home() conditional tag for first page only (18 posts)

  1. iM1
    Member
    Posted 7 years ago #

    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

  2. moshu
    Member
    Posted 7 years ago #

    The music is a very bad idea: don't do it unless you want to chase away visitors...

    Conditional_Tags#A_Paged_Page

  3. iM1
    Member
    Posted 7 years ago #

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

  4. iM1
    Member
    Posted 7 years ago #

    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?

  5. iM1
    Member
    Posted 7 years ago #

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

  6. moshu
    Member
    Posted 7 years ago #

    is home AND is NOT paged

  7. iM1
    Member
    Posted 7 years ago #

    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?

  8. HairyLove
    Member
    Posted 7 years ago #

    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.

  9. HairyLove
    Member
    Posted 7 years ago #

    Found it.

    Use this:

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

    It excludes older pages.

    More here

  10. nicholas77
    Member
    Posted 6 years ago #

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

  11. wpceo
    Member
    Posted 6 years ago #

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

  12. relaxedguy
    Member
    Posted 6 years ago #

    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?

  13. Justin Tadlock

    Posted 6 years ago #

    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.

  14. relaxedguy
    Member
    Posted 6 years ago #

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

  15. Justin Tadlock

    Posted 6 years ago #

    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. ;)

  16. relaxedguy
    Member
    Posted 6 years ago #

    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.

  17. relaxedguy
    Member
    Posted 6 years ago #

    Greenshady, this is what I'm talking about.

    http://rickbeckman.com/thesis-openhook/

  18. Justin Tadlock

    Posted 6 years ago #

    Yeah, this type of functionality should be within themes and plugins.

    I also have released something similar to Thesis OpenHook for my Hybrid theme:
    http://themehybrid.com/archives/2008/12/hybrid-hook-wordpress-plugin

    It allows you to add PHP to any of the theme's action hooks from the WP dashboard.

    Conditional data display like we're talking about should be built into the Widget GUI.

    Most definitely. From everything I've heard, the widget system will get a complete overhaul in 2.8.

    I only wish they'd add something like the Widget Logic plugin to the widgets.

Topic Closed

This topic has been closed to new replies.

About this Topic