WordPress.org

Ready to get started?Download WordPress

Forums

Conditional tag for blog page not working (8 posts)

  1. rembem
    Member
    Posted 6 years ago #

    I am using WP 2.5.1,
    In Settings>Reading, I have set the Posts page to a static page called "My blog"
    Everything works correctly, the posts show up on this page.

    My problem is that I cannot find a single way to target this page with Conditional Tags. It does not react to is_page, is_archive, is_date, nothing.
    The id of the "My blog" page in the tree is 4. I've tried is_page('4'), even tried is_page_template().

    The only thing it reacts to is excluding everything:
    !is_date() and !is_page() and !is_category() and !is_archive() and !is_single()

    I don't get, why this page is not an archive and not a page...

    Any ideas?
    Thanks, Remco

  2. lexhair
    Member
    Posted 6 years ago #

    How about using is_front_page()? It's new in WP 2.5.

  3. moshu
    Member
    Posted 6 years ago #

    Well, that's not what the OP wants.
    When you select a "frontpage" you need to select a "posts page", too.

    is_front_page - works for..err, the frontpage.
    Nothing works for the "posts page"; just checked.

  4. rembem
    Member
    Posted 6 years ago #

    Yes that was also my conclusion.
    Excluding everything is the only option, and targeting the other pages.

    thanks guys.

  5. Doodlebee
    Member
    Posted 6 years ago #

    Actually, this - in a roundabout way - solved *my* problem. I have a static page ("Welcome") set as my home page, and another Static page ("Articles") set as my blog page.

    If I use the if(is_home()) conditional, the blog page would pick it up.

    I didn't know about the "if(is_fonrt_page())" option. When I used that, my home page ("Welcome") saw *that* conditional and applied it. I could then use the "is_home()" for the blog pages, wthout affecting the index page.

    So that should solve your problem - target it as home and you'll get what you need done.

  6. rembem
    Member
    Posted 6 years ago #

    Thanks for your post Doodlebee!

    I just tried and it works, I never thought of using 'is_home' for the blogpage. I thought of 'is_home' as meaning is_frontpage...

    You saved my day.

  7. SeanAUS120
    Member
    Posted 5 years ago #

    Wow, only just stumbled on this post today. I've been looking for a solution for that problem all week!

    Using "is_home()" definitely works!

  8. Greg Rickaby
    Member
    Posted 5 years ago #

    @SeanAus120

    SAME HERE! Great post...and lame tag: "is_home()" seriously? LOL

Topic Closed

This topic has been closed to new replies.

About this Topic