WordPress.org

Support

Support » Themes and Templates » Query if on front-page? home? index?

Query if on front-page? home? index?

  • 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

Viewing 6 replies - 1 through 6 (of 6 total)
  • MichaelH

    @michaelh

    Look at the various Conditional Tags.

    equalmark

    @equalmark

    Try this:

    <?php if(is_front_page() ) { ?>
    
    //do stuff
    
    <?php } ?>

    This works too:

    <?php if(is_home() ) {
    
    //do stuff
    
    } else {
    
    //do stuff
    
    } ?>

    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.

    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.

    My apologies, thank you to Mark as well.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Query if on front-page? home? index?’ is closed to new replies.
Skip to toolbar