Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I just did a normal form that redirects the results from index.php to search.php, where I pasted the normal loop code of my index.php that displays the latest posts, and I noticed only the posts from my search query appears. I did not put any filters with $_GET in the loop, is it possible search.php automaticly filters the loop to get results that matches my search???

share|improve this question

1 Answer 1

up vote 1 down vote accepted

The loop doesn not display the latest posts, it just shows the posts the main query has found. On your search page the main query returns search results, and you can change its order (we have plenty of examples for that on our site).

WordPress looks for the parameter s or /search/ in the request URI and decides to do a search query then. That’s what you see as results. You don’t have to do anything more, if you are happy with those results. It happens automatically.

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.