Separate search results by category
-
I’m trying to get separate my search results by specific categories. So for instance if I were to type “search item”. I would receive a results page like the following.
5 results for “search item”
Videos (2)
– Result 1
– Result 2Images (3)
– Result 1
– Result 2I’m using the following code to attempt to achieve this
<h1>Search: <?php echo $wp_query->found_posts; ?> results for "<?php echo wp_specialchars($s); ?>"</h1> <?php query_posts($query_string.'&cat='.$theme_motionstok_cat); if (have_posts()) : ?> <?php include('search-content.php'); ?> <?php endif; wp_reset_query(); ?> <div class="clear"></div> <?php query_posts($query_string.'&cat='.$theme_photostok_cat); if (have_posts()) : ?> <?php include('search-content.php'); ?> <?php endif; wp_reset_query(); ?> <div class="clear"></div>
The problem is the category variable in query_posts seems to be ignored and every loop returns the same search results. Any help would be appreciated.
- The topic ‘Separate search results by category’ is closed to new replies.