Title: Search Form Problems
Last modified: August 19, 2016

---

# Search Form Problems

 *  [fanderzzon](https://wordpress.org/support/users/fanderzzon/)
 * (@fanderzzon)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/search-form-problems/)
 * Hi WordPress friends,
 * I’ve worked on my site a while and here’s the result.
    [http://www.fiddeandersson.se/](http://www.fiddeandersson.se/)
 * I have problem to get the search function to work.
    The search button in the 
   header.php i’m using this code:
 *     ```
       <div id="search">
          			<form method="get" id="searchform" action="<?php bloginfo('url'); ?>/">
          			<label class="hidden" for="s"><?php _e(''); ?></label>
          			<input type="text" value="<?php the_search_query(); ?>" name="s" id="s" size="30" />
          			<input type="submit" id="searchsubmit" value="SEARCH" /> </form>
          		</div>
       ```
   
 * For the searchform.php i use this code:
 *     ```
       <?php
       /*
       Template Name: Search
       */
       ?>
   
       <?php get_header(); ?>
   
       <?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]] = $query_split[1];
       } // foreach
   
       $search = new WP_Query($search_query);
       ?>
   
       <div id="content">
   
       <h2>Sökresultat</h2>
   
       	<?php global $wp_query; $total_results = $wp_query->found_posts; ?>
   
       </div>
   
       <?php get_footer(); ?>
       ```
   
 * I have tried to read the docs about this but i don’t get it to work.
    Does someone
   have another good tutorial that i can use to create a search function?
 * Best regards
    Fidde

Viewing 1 replies (of 1 total)

 *  Thread Starter [fanderzzon](https://wordpress.org/support/users/fanderzzon/)
 * (@fanderzzon)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/search-form-problems/#post-1680610)
 * Do i need 3 files, search.php, searchform.php and searchpage.php?

Viewing 1 replies (of 1 total)

The topic ‘Search Form Problems’ is closed to new replies.

## Tags

 * [search function](https://wordpress.org/support/topic-tag/search-function/)

 * 1 reply
 * 1 participant
 * Last reply from: [fanderzzon](https://wordpress.org/support/users/fanderzzon/)
 * Last activity: [15 years, 8 months ago](https://wordpress.org/support/topic/search-form-problems/#post-1680610)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
