I have google custom search implemented on my blog in a 2-page format, it works OK.
i’m trying to add the number of posts found, and also the search query from the user to be displayed above my search results, i have tried the following php but it seems to only show ’74’ results for EVERY search, and the search query itself does not display between the “” speech marks, my search template:
<?php /* Template Name: Search Results */ ?> <?php /** * @package WordPress * @subpackage Default_Theme */ get_header(); ?> <div id="content-page"> <h2>Your Google Search Results</h2> <?php $mySearch =& new WP_Query("s=$s & showposts=-1"); $num = $mySearch->post_count; echo $num.' useful search results for "'; the_search_query(); ?> <!-- Place this tag where you want the search results to render --> <gcse:searchresults-only></gcse:searchresults-only> <!-- Search Results code above this line --> </div> <?php include ( "sidebar2.php" ) ; ?> <?php get_sidebar(); ?> <?php get_footer(); ?>
i have also tried:
<?php the_search_query(); ?>
<?php echo 'Search Results for "'; the_search_query(); echo '"'; ?>
before my search results, but it doesn’t seem to pull the search query in.
i’m stumped, any gcse experts in the house?
my blog: http://artbyherbie.com
- The topic ‘Search query and results count not showing in search results’ is closed to new replies.