404 or a failed search breaks custom loops
-
Hi,
I’m using this loop in header.php to pull in the latest posts thumbnails.
<?php $query = new WP_Query(); $query->query('posts_per_page=30'); ?> <?php if (have_posts()) : ?> <?php while ($query->have_posts()) : $query->the_post(); ?> <a href="<?php the_permalink(); ?>" title="View <?php the_title(); ?>"><?php the_post_thumbnail('thumbnail'); ?></a> <?php endwhile; ?> <?php endif; wp_reset_query(); ?>
Which works fine, but if you make the site 404 or perform a search that doesn’t bring back any results it affects the custom loop too (not displaying anything).
Any ideas how to stop 404’s and failed searches from interfering?
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘404 or a failed search breaks custom loops’ is closed to new replies.