I'm trying to build a custom search results page. The problem I'm running into is that when I enter a search term ; say 'gaming', it will only return one result, being the latest result. I have my blog setup to display only one article at a time. However, I found a way to circumvent the search results page by logging into wp-admin -> settings -> reading -> and changing the blog page displays one post to say for example 10.
Then when I try searching for gaming it returns more than one result (it'll give me 10). However, I don't want this. I want my sites blog page to only show one article, and the results page to display more than one result. How can I go about fixing this?
This is what my
search.php looks like. I created a
searchpage.php and am including it using PHP to grab the
<!-- SEARCH PAGE --> <div id="search-results" class="wrapper" role="search"> <h2> Search Results</h2> <!-- COUNT RESULTS --> <div class="results"> <?php /* Search Count */ $allsearch = &new WP_Query("s=$s&showposts=-1"); $key = wp_specialchars($s, 1); $count = $allsearch->post_count; _e(''); _e('"<span class="search-terms">'); echo $key; _e('</span>"'); _e(' — found '); echo $count . ' '; _e('articles'); wp_reset_query(); ?> </div> <!-- / COUNT RESULTS --> <?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?> <!-- LIST RESULTS --> <section> <h3> <li> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a> - <span class="search-time"><?php the_time('F, j, Y') ?></span> </li> </h3> </section> <!-- / LIST RESULTS --> <?php endwhile; else: ?> <!-- 404 SEARCH --> <div class="404-search"> <?php _e("Oops... We couldn't find what you were searching for. Please try again"); ?> </div> <!-- / 404 SEARCH --> <?php endif; ?> </div> <!-- / SEARCH PAGE -->