Support » Themes and Templates » search form not working

  • My search form is not working. In searchform.php I have:

    <form id="searchform" action="<?php bloginfo('url'); ?>/" method="get" role="search">
        	<label for="s">Search</label>
        	<input type="text" name=s"" />
        	<input type="submit" name="submit" value="Search" />

    I’m pulling it into my header.php with:

    <?php include (TEMPLATEPATH . '/searchform.php'); ?>

    I am pretty new to PHP so I’m sure I am missing something, but when I search for something, it returns me to the homepage with the url ‘http://localhost:8888/PolishSonWP/?s%22%22=searchterm&submit=Search’

    What’s going on?

Viewing 5 replies - 1 through 5 (of 5 total)
  • esmi


    Forum Moderator

    Try using <?php get_search_form();?>

    You can use:

    <?php get_search_form(); ?>

    Rather than the include

    Also you have an typo on your searchform.php whereby:


    should be

    If it’s still failing try changing:
    <?php bloginfo('url'); ?>
    <?php bloginfo('home'); ?>
    Just because my theme has this so might make a difference.



    Forum Moderator

    should be name=”s”

    Oh well spotted!

    FWIW, all of my search forms use <?php bloginfo('url'); ?> and I’ve never had any problems. However, it might be worth noting that, if you submit an empty search on most themes, you will be sent straight back to the Home page. No error messages. Nothing.

    Yup I still have to implement the helpful fix you’ve provided to this!

    I knew it was something little I was overlooking. The name typo was the entire problem. Good eye xdesi. Thanks both of you.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘search form not working’ is closed to new replies.