Search Form Problems
-
Hi WordPress friends,
I’ve worked on my site a while and here’s the result.
https://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)
Viewing 1 replies (of 1 total)
- The topic ‘Search Form Problems’ is closed to new replies.