is_home() || is_front_page() not working ! [solved]

There are some situations when the WP conditional tags doesn’t work. Be it any reason like say: Multiple WordPress loops, faulty use of query_posts(…) or issue in the code itself. Basically this problem occurs when there is a change in the main query by the use of query_posts(). Fortunately WordPress always keeps the original, unaltered query intact. So, to get back that where all the conditional tags works we have to use the wp_reset_query().

Just place this function call wp_reset_query() before the conditional tag to solve this issue of WordPress’s is_home() || is_front_page() is not working. I faced this issue once and wp_reset_query() solved my problem.



     

     

Comments

9 responses to “is_home() || is_front_page() not working ! [solved]”

  1. Lukas Avatar

    PERFECT – this is just what I was searching for!

    I was googling around for at least 30 mins, because I’m using “is_front_page()” after I altered the wp_query. I only want to display posts of a certain category on the front page followed by the latest post of another category.

    Thank you very much, that made my day!

  2. […] Nguồn bài viết : is_home() || is_front_page() not working.. ! […]

  3. Chris Avatar
    Chris

    Many thanks -this is a lifesaver!

  4. Ravi Avatar
    Ravi

    Many Thanks …

  5. Jean Lombardo Avatar

    The Best Solutions for WordPress 4.6.1 compatible, excelent, thanks

  6. 6clicks Avatar

    many thank’s that work like a cham!

  7. Naveen Gautam Avatar
    Naveen Gautam

    Thanks a ton!

  8. Rosa Bosma Avatar

    Thank you so much, this is exactly what I’ve been looking for. It’s really valuable that you posted this. 🙂

  9. Amarjeet Prasad Avatar
    Amarjeet Prasad

    Thanks dude..keep it up.

Leave a Reply

Your email address will not be published. Required fields are marked *