WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When there is no value for parameter "s" , it redirects automatically to homepage. Instead of this , I want to show all the information from my custom sql query. how can i do this??

share|improve this question
up vote 0 down vote accepted

You can pass s=%20 as your search string, but thats kinda hackish.

If what you are trying to achieve is to use your search.php template but with "controled" search results, consider using this:


global $query_string; // fetch query string being used
query_posts($query_string . '&posts_per_page=20') // add your terms to it.

share|improve this answer

Create a custom search form and use <input type="hidden" name="s" value="whatever" /> in it, of course along with your usual search form (at the least an <input type="text" name="search" />).

Then, $_GET['s'] will always be set. Remember to create a custom search page running your custom query (with $_GET['search'] for the search terms), or you will find yourself always searching for the placeholder value you put in $_GET['s'].

You can see a live example of a solution similar to this at my site Allt du behöver (unfortunately in Swedish but I think you can figure out how it works anyways).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.