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

I'm attempting to add a Back to Search Results link which in essence will simply link back to the starting search page - for example /?s=test. I've taken a look at the global query vars and do see there is a paged query argument available -- which does do the job when the permalink structure is set to the default - for example /?s=test&paged=2 run through remove_query_arg(array('paged')) corectly becomes /?s=test. But, when you visit a second page of search results and you use anything but the default permalink structure - it is not removing page/2 which is what the default pagination structure outputs.

I believe I could just use $_GET['s'] and append that onto the site URL.. but I figured I'd ask here to see if there is a better way to do this. Thanks!

share|improve this question
up vote 2 down vote accepted

http://codex.wordpress.org/Function_Reference/get_search_link was what I was looking for.

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.