I have a search form which uses RELEVANSSI plugin to perform search and display Search Results. On my Search Results page there is pagination and Search Filters(hyperlinks) which allows user to show 10, 20 or 30 records on screen.
The Issue: In my website I have some internal pages which have different HEADER AND FOOTER and a Search BOX. By adding some checks If user performs search from these internal pages then it will load relevant and correct header and footer. But if I click on Pagination Filter or Search Filters (Show 10 Records, show 20 records) then it will load main website header and footer.
I need a way to pass some variable which recognizes that from which page user come and according to that variable it will load header and footer.
Thanks
I have a search form which uses RELEVANSSI plugin to perform search and display Search Results. On my Search Results page there is pagination and Search Filters(hyperlinks) which allows user to show 10, 20 or 30 records on screen.
The Issue: In my website I have some internal pages which have different HEADER AND FOOTER and a Search BOX. By adding some checks If user performs search from these internal pages then it will load relevant and correct header and footer. But if I click on Pagination Filter or Search Filters (Show 10 Records, show 20 records) then it will load main website header and footer.
I need a way to pass some variable which recognizes that from which page user come and according to that variable it will load header and footer.
Thanks
Share Improve this question edited Mar 19, 2019 at 7:55 Eshban Bahadur asked Mar 19, 2019 at 7:43 Eshban BahadurEshban Bahadur 1251 silver badge7 bronze badges1 Answer
Reset to default 0Just use wp_get_referer()
, and a few other functions to get the simple name of the referring page, e.g.
if (basename(parse_url(wp_get_referer(), PHP_URL_PATH)) == 'my-search-page') {
(Or you could use string searching or matching instead of parse_url
and basename
).
(Also note wp_get_referer
is deliberately misspelled. It originates in a misspelling in one of the web standards)
Addendum
Might have to tweak this a bit to deal with the case where there's no referrer (e.g. a bookmark was used to get to the page).
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745634049a4637280.html
评论列表(0条)