WordPress.org

Ready to get started?Download WordPress

Forums

Query if on front-page? home? index? (7 posts)

  1. sepp88
    Member
    Posted 4 years ago #

    Helly,

    is it possible to query if i'm on the startpage of my blog or elsewhere. I want to enable a feature just if i'm on the frontpage of my blog.

    regards

  2. MichaelH
    Member
    Posted 4 years ago #

    Look at the various Conditional Tags.

  3. equalmark
    Member
    Posted 4 years ago #

    Try this:

    <?php if(is_front_page() ) { ?>
    
    //do stuff
    
    <?php } ?>
  4. Baki Goxhaj
    Member
    Posted 4 years ago #

    This works too:

    <?php if(is_home() ) {
    
    //do stuff
    
    } else {
    
    //do stuff
    
    } ?>
  5. Mvied
    Member
    Posted 4 years ago #

    I'd just like to point out that the is_home() function is true if you're on the main blog page, and the is_front_page() function can be the same page unless you have a static front page set, then it will only be true on that page.

  6. sdriedger
    Member
    Posted 3 years ago #

    Thank you banago and Mvied, this has helped me resolve an issue with showing a particular widget in the sidebar on the home page only. I can see many uses for it in the future.

  7. sdriedger
    Member
    Posted 3 years ago #

    My apologies, thank you to Mark as well.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.