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 would like to get the last term that was searched, but when not in the search.php page. For that, I know, I could use get_search_query() function, but if user clicks on a post for example, so he is now in the single item and that function will retrieve an empty string. I want to preserve that search phrase and get it on other page.

Any ideas?

Thanks

share|improve this question
    
are you looking for 2 day storage or more? Or are you looking for just as long as the users is still logged in. If user logs out then wipe search history –  xLRDxREVENGEx May 23 '11 at 4:20

2 Answers 2

up vote 4 down vote accepted

Best solution would be to store the search phrase on the client-side via local storage or, where not available, in a cookie.

share|improve this answer

If you don't want to go the client-side way you might use the WordPress Transients API or just regular PHP sessions as suggested here: http://old.nabble.com/The-WordPress-way-to-store-temporary-per-user-data-(sessions)--td29723244.html

share|improve this answer

Your Answer

 
discard

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.