Support » Fixing WordPress » conditionnal tags on sidebar

  • Hi,

    Into the sidebar (sidebar.php), I show articles I want :
    – A (named) static article
    – last articles
    For that, I use query_posts and the loop.

    Thus, I launch two requests query_posts and two loop (is it better to use get_posts with a foreach ?)
    It works as I wish… but this behavior must be only for the homepage (I use home.php) and problem is here.

    Actually, I wanted to use conditional tags in sidebar but that doesn’t work : neither is_home(), nor is_front_page() return correct value (always false while I am on the homepage – root of website -).

    So, why it doesn’t work and how can I get it work ?

    Is it stupid to use several loops and is it better to use other type of request (and perhaps directly MySQL request) ?

    Thank you.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Behavior is very strange :

    $wp_query[post][is_home] = false when I choose “Your latest posts” (Settings > Reading)

    $wp_query[post][is_home] = false when I choose “A static page”-“Front page”-(page wanted in home)

    $wp_query[post][is_home] = true when I choose “A static page”-“Posts page” (but doesn’t show what I want)

    is_home() seems to be buggy !

    you need to reset the query before the conditional statement
    <?php wp_reset_query(); ?>

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘conditionnal tags on sidebar’ is closed to new replies.