Passing variable from searchform.php to search.php
-
I’m using (trying to use) the search.php to choose one of two templates (English or Thai) for returning results depending on where the search function was executed — from the English side where everything is displayed from one parent category or from the Thai side with a different parent category. My search.php can easily parse the parent category and display using the appropriate language template when it has a result, but when “no result” , I need another way for the search.php to know which language template to choose.
Question 1: Is it possible to set/use a variable in the searchform.php that can still be accessed from the search.php after the search has been performed?
Also, when “no result” occurs wp displays “Sorry, no posts matched your criteria”. I can’t find where I can edit or set any kind of condition for this default message.
Question 2: Should I be inserting a conditional statement in my search.php file that selects my own “no result” message (as opposed to this default “no result” message) to display when finding no results? If so, could someone provide me with the relevant code for testing for “no results found” from the search function?
I’ve read in the codex and the forums about setting up search pages, etc., but these two issues do not seem to be addressed.
Thank you!
- The topic ‘Passing variable from searchform.php to search.php’ is closed to new replies.