• Hi,
    I have a search box in my header but no matter what you search for, it just does not return any results.
    This is in my header:

    <form action="/search/search.php" method="get">
    						<p><input type="text" name="query" id="query" class="keyword"/>	</p>
    						<p class="button"><input name="" type="image" src="<?php bloginfo('template_directory'); ?>/images/searchbutton.gif" alt="Search" /></p>
    						<p class="hide">	<input type="hidden" name="search" value="1" /> </p>
    						</form>

    And this is in my search.php file:

    <?php if ( have_posts() ) : ?>
    				<h1 class="page-title"><?php printf( __( 'Search Results for: %s', 'twentyten' ), '<span>' . get_search_query() . '</span>' ); ?></h1>
    				<?php
    				/* Run the loop for the search to output the results.
    				 * If you want to overload this in a child theme then include a file
    				 * called loop-search.php and that will be used instead.
    				 */
    				 get_template_part( 'loop', 'search' );
    				?>

    I’ve had a search through loop.php but cant seem to find anything relating to “search” in there, is this the problem?

    Thanks.

Viewing 1 replies (of 1 total)
  • Are you using Twenty Ten? You only have part of the search.php copied here. If you ARE using Twenty Ten, then you don’t have to copy the entire search.php to your child theme, just create a loop-search.php in your child theme as it suggests to format the results differently. The loop.php isn’t going to say anything specifically about search, because it’s simply going to give WordPress instructions on how to output whatever the query asks for, whether that’s search results, a specific page, or whatever.
    Your search.php above is incomplete, as it doesn’t even end the if statement from the first line.
    If you aren’t actually using Twenty Ten, and aren’t using its modular loop structure, there are simpler ways to write your search.php…
    (I actually hacked one together based on the Twenty Eleven search.php, and found this much easier than working from the Twenty Ten examples.)

    You might also like to make your life easier by either calling the default search form, or create your own as searchform.php and call that from anywhere you need a search form, instead of manually coding it into each spot.
    See Function Reference: get_search_form for details.

Viewing 1 replies (of 1 total)
  • The topic ‘Search form not returning any results’ is closed to new replies.