基于引用页面设置条件模板

I am trying to create a conditional template in wordpres where the condition should only be passed if the referring page is the search page:

I am aware that url_to_postid(wp_get_referer()) would get me the page id of the refering page but in my case this does not work as the search page does not have an id. Is there any other way I can do this?

EDIT: the wordpress url for the search would be http:/mywebsite.com/?s=aaa where is the search term

Depending what your using this for and how reliable it needs to be you could use $_SERVER['HTTP_REFERER']

Taken from PHP Manual

The address of the page (if any) which referred the user agent to the current page. This is set by the user agent. Not all user agents will set this, and some provide the ability to modify HTTP_REFERER as a feature. In short, it cannot really be trusted.

You might be better off either using post/get to send a parameter to the next page, or using a session if you need more reliability and or control.