WordPress.org

Ready to get started?Download WordPress

Forums

is_page() not working for static "Posts Page" (3 posts)

  1. Glenn Ansley
    Member
    Posted 6 years ago #

    Hi,
    I have setup a static posts page. The WordPress Page is "Weblog" with a slug of 'weblog'. In my sidebar.php, I have the following code:

    if(is_page('weblog')){
     //DO stuff like show categories
    }

    This doesn't seem to work.
    However, if I go to my settings and remove the static setting for blog posts page, and then navigate back to the weblog page, the above code outputs the expected result.

    It seems, then, that signifying a page as the static page for Blog Posts breaks the is_page() function for that page. Is this a known issue? I couldn't find anything mentioning it.

    Thanks.

  2. Samuel Wood (Otto)
    Tech Ninja
    Posted 6 years ago #

    The is_home() stuff got messed around with a bit in this release. Try using just is_home() to check for the main blog page. If you need to check for the static front page, try is_front_page().

  3. Glenn Ansley
    Member
    Posted 6 years ago #

    Thanks Otto. Should I do this even if the weblog page mentioned above is different from the home page? I have another page with slug of sitehome set as the static Home page and it's working fine.

Topic Closed

This topic has been closed to new replies.

About this Topic