Support » Fixing WordPress » Custom search

  • hello,

    I made a custom theme and all is working perfect except the search form.

    I don’t understand how it works and I can’t make it works.

    I created a page-search.php as a page template and I added a page called search in my wordpress that uses this template.

    But I don’t know what code I have to use in my page-search.php template to throw any results.

    Could anyone help me.

    Thanks a lot

Viewing 7 replies - 1 through 7 (of 7 total)
  • Moderator keesiemeijer



    I followed this tutorial two times and I can’t get it work.

    The problem is that I can’t make my custom search page works.

    If I go to it shows the sear page, but if I introducce a search string I got and error 404 page not found.

    I don’t know what to do, can you help me???

    This is my custom search page:

    Template Name: page-search
    Develop by Alvaro Vieitez
    Company: Framestorm
    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);
    <?php get_header(); ?>
    		<div id="container">
    			Resultados de búsqueda
    			<?php get_search_form(); ?>
    		</div><!-- #container -->
    <?php get_footer(); ?>

    [Moderator Note: Please post code or markup snippets between backticks or use the code button. Or better still – use the pastebin. As it stands, your code may now have been permanently damaged/corrupted by the forum’s parser.]

    Moderator keesiemeijer


    Does your theme have a template file search.php.

    If not, duplicate your index.php (if it does not have a query on the loop) and rename it search.php.

    Do a search and see if it uses the search.php template for the results.

    Ok, my theme didn’t have a templete file search.php, but now I created it and yes, it uses it.

    Following the tutorial I think I have understood that I don’t need the search.php file and that I have to created a custom searchpage.php as a template.

    What i should do now???

    Thanks a lot

    Moderator keesiemeijer


    Following the tutorial I think I have understood that I don’t need the search.php

    search.php is a template that displays the search results. index.php is used if your theme doesn’t have a search.php.

    Do you still get a 404 after a search?

    No thanks, now it is working and I don’t get any error.

    I was wrong, I insisted on creating a page in wordpress and assign to it a template named as page-search.php

    It is much simple just using the search.php.


    Moderator keesiemeijer


    No problem. I’m glad you got it resolved 🙂

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Custom search’ is closed to new replies.