Title: wordpress default search doesn&#039;t work
Last modified: August 21, 2016

---

# wordpress default search doesn't work

 *  [igorlaszlo](https://wordpress.org/support/users/igorlaszlo/)
 * (@igorlaszlo)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/wordpress-default-search-doesnt-work/)
 * Hello,
 * whatever word i type in my default search form, it turns to zero result. I installed
   Search Everything wp plugin which has a trial search in the admin side and it
   works very well, it even highlights all words in the front end. BUT, this plugin
   uses the default wp search form at the front end, and it does not work there,
   even with this plugin…
 * Do you have some idea what is the problem ? I use my own template based on twenty
   eleven. The search.php contains :
 *     ```
       <?php
       /**
        * The template for displaying Search Results pages.
        *
        * @package WordPress
        * @subpackage IL-Design
        * @since IL Web-Design 1.0
        */
   
       get_header(); ?>
   
       		<section id="primary">
       			<div id="content" role="main">
   
       			<?php if ( have_posts() ) : ?>
   
       				<header class="page-header">
       					<h1 class="page-title"><?php printf( __( 'Search Results for: %s', 'ilwebdesign' ), '<span>' . get_search_query() . '</span>' ); ?></h1>
       				</header>
   
       				<?php ilwebdesign_content_nav( 'nav-above' ); ?>
   
       				<?php /* Start the Loop */ ?>
       				<?php while ( have_posts() ) : the_post(); ?>
   
       					<?php
       						/* Include the Post-Format-specific template for the content.
       						 * If you want to overload this in a child theme then include a file
       						 * called content-___.php (where ___ is the Post Format name) and that will be used instead.
       						 */
       						get_template_part( 'content', get_post_format() );
       					?>
   
       				<?php endwhile; ?>
   
       				<?php ilwebdesign_content_nav( 'nav-below' ); ?>
   
       			<?php else : ?>
   
       				<article id="post-0" class="post no-results not-found">
       					<header class="entry-header">
       						<h1 class="entry-title"><?php _e( 'Nothing Found', 'ilwebdesign' ); ?></h1>
       					</header><!-- .entry-header -->
   
       					<div class="entry-content">
       						<p><?php _e( 'Sorry, but nothing matched your search criteria. Please try again with some different keywords.', 'ilwebdesign' ); ?></p>
       						<?php get_search_form(); ?>
       					</div><!-- .entry-content -->
       				</article><!-- #post-0 -->
   
       			<?php endif; ?>
   
       			</div><!-- #content -->
       		</section><!-- #primary -->
   
       <?php get_sidebar(); ?>
       <?php get_footer(); ?>
       ```
   
 * The searchform.php contains :
 *     ```
       <?php
       /**
        * The template for displaying search forms in Twenty Eleven
        *
        * @package WordPress
        * @subpackage IL-Design
        * @since IL Web-Design 1.0
        */
       ?>
       	<form method="get" id="searchform" action="<?php echo esc_url( home_url( '/' ) ); ?>">
       		<label for="s" class="assistive-text"><?php _e( 'Search', 'ilwebdesign' ); ?></label>
       		<input type="text" class="field" name="s" id="s" placeholder="<?php esc_attr_e( 'Search', 'ilwebdesign' ); ?>" />
       		<input type="submit" class="submit" name="submit" id="searchsubmit" value="<?php esc_attr_e( 'Search', 'ilwebdesign' ); ?>" />
       	</form>
       ```
   
 * Thanks for your ideas in advance !

Viewing 1 replies (of 1 total)

 *  Thread Starter [igorlaszlo](https://wordpress.org/support/users/igorlaszlo/)
 * (@igorlaszlo)
 * [11 years, 11 months ago](https://wordpress.org/support/topic/wordpress-default-search-doesnt-work/#post-4949867)
 * In the meantime i realized that the zero search result shows up on the 404.php(
   [http://www.my-site.com/undefined](http://www.my-site.com/undefined)) page and
   not on a page what search.php generates… so, i guesse there is a problem with
   an url somewhen in my codes ?
 * I read also in the codex but for me it is ununderstandable, where should i paste
   these two codes exactly ? :
 * >  Preserving Search Page Results and Pagination
   > Search results and Pagination may stop working when applying customization 
   > to the search template. To avoid these issues the first thing any developer
   > needs to do is add the following code to the start of their Search template
   > to ensure that the original WordPress query is preserved. To customize the 
   > query append additional arguments to (array) $search_query. Execute the $search_query
   > through a new $wp_query object, more information on the WP_Query object can
   > be found at [https://codex.wordpress.org/Class_Reference/WP_Query](https://codex.wordpress.org/Class_Reference/WP_Query)
   >     ```
   >     <?php
   >     global $query_string;
   > 
   >     $query_args = explode("&", $query_string);
   >     $search_query = array();
   > 
   >     foreach($query_args as $key => $string) {
   >     	$query_split = explode("=", $string);
   >     	$search_query[$query_split[0]] = urldecode($query_split[1]);
   >     } // foreach
   > 
   >     $search = new WP_Query($search_query);
   >     ?>
   >     ```
   > 
   > Additional customization arguments can be found on the Codex at [https://codex.wordpress.org/Class_Reference/WP_Query](https://codex.wordpress.org/Class_Reference/WP_Query)
   > 
   > Display Total Results
   > To access the total number of search results from a search, you should retrieve
   > the total number of posts found using the wp_query object.
   >     ```
   >     <?php
   >     global $wp_query;
   >     $total_results = $wp_query->found_posts;
   >     ?>
   >     ```
   > 

Viewing 1 replies (of 1 total)

The topic ‘wordpress default search doesn't work’ is closed to new replies.

## Tags

 * [Searchform](https://wordpress.org/support/topic-tag/searchform/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 1 participant
 * Last reply from: [igorlaszlo](https://wordpress.org/support/users/igorlaszlo/)
 * Last activity: [11 years, 11 months ago](https://wordpress.org/support/topic/wordpress-default-search-doesnt-work/#post-4949867)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
