WordPress.org

Ready to get started?Download WordPress

Forums

is_home bug? (5 posts)

  1. drphil9001
    Member
    Posted 6 years ago #

    I am using WP as a CMS with a custom theme that has home.php and a WP Page entitled "Blog" with a custom template. WP is in a "wordpress" dir and the site URL is located at http://mydomain/.

    When I browse to either the site URL or the Blog Page (ie http://mydomain/?page_id=1) is_home returns true. I would expect is_home() to only return true when at the site URL. Is this the correct expected behavior or is this a bug in is_home()?

  2. Dazzer
    Member
    Posted 6 years ago #

    Its intended.

    is_home refers to very first page that is displayed "BY DEFAULT". That means, if you changed the home page to display a static page, is_home returns false.

    Silliness, I know.

    As a substitution, use compare bloginfo('url') with the current url to find out if it is the front page.

    I believe a is_frontpage() will come out in 2.4... or hopefully anyway.

  3. drphil9001
    Member
    Posted 6 years ago #

    Ah, that is a little silliness, but not what is going on in my situation (I think).

    I am not using the Options->Reading pane to set a static home page and the blog page. I have a home.php in my theme that is used to render the home page (with no blog entries). I then have a WP Page called Blog with its own template to render blog entries. I simply put links to it in my header.php.

    So is_home() returns true when home.php is rendered AND true when the blog page is rendered. My problem isn't that when home.php is rendered that is_home is true, but rather the page I use to display blog entries. So right now I have to have check to see if I am on the home page and not on the blog page to get the "active" page to show properly in my header.

  4. L2Lulu
    Member
    Posted 6 years ago #

    I'm having a similar issue -- I can't get WP to recognize my true home page. Comparing the url of the current page with bloginfo('url') will work for me. Problem is, I don't know how to retrieve the url of the current page. Any ideas? Thanks.

  5. gulflee
    Member
    Posted 6 years ago #

    i m facing this prob too
    if is themes isu then u have to work more
    <php if(is_page() || (is_category() || is_single() ) { } ?>
    this maybe help in a mean while.

Topic Closed

This topic has been closed to new replies.

About this Topic