1

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

  • 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
4

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

| improve this answer | |
0

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

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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