最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

How to load page template according to the Searched Page

programmeradmin1浏览0评论

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 badges
Add a comment  | 

1 Answer 1

Reset to default 0

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)

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

发布评论

评论列表(0)

  1. 暂无评论