Loop of recent posts in search.php
-
At the top of a search results page I’m working on, I’d like to have a loop of the ten most recent posts in a certain category (that is, above the search results). I’ve got this working fine on single posts, but in search.php it returns the ten most recent search results within that category.
<?php if (have_posts()) : $recentProducts = new WP_Query(); $recentProducts->query('category_name=products&showposts=10'); while ($recentProducts->have_posts()) : $recentProducts->the_post(); ?> <!--POSTS GO HERE--> <?php endwhile; ?> <?php else : ?> <?php endif; ?>
This is followed by the search results. Is this possible? Am I missing something?
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Loop of recent posts in search.php’ is closed to new replies.