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.

Sample Code:
<?php wp_reset_query(); ?>
<?php if(is_home() || is_front_page()): ?>
     <! Do the things here... >
<?php else: ?>
     <! Else part goes here...  >
<?php endif;  ?>


Leave a Reply

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