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
Best solution would be to store the search phrase on the client-side via local storage or, where not available, in a cookie.
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