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.


1 Answer 1


Just 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_urland basename).

(Also note wp_get_referer is deliberately misspelled. It originates in a misspelling in one of the web standards)

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).

  • thanks. let me check it.
    – Eshban
    Apr 3, 2019 at 8:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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