I have tried to change the results URL based on the page URL parameters. eg. $_GET[‘page_id’] may I know how do modify the code but I can’t get any value after I have do some modification.
function asp_custom_link_results( $results ) {
global $page_id;
// Parse through each result item
foreach ($results as $k=>$v) {
/**
* In this context the
* $results[$k]->link
* variable holds the result link. Make modifications to that variable.
*/
$results[$k]->link = ‘https://google.com’.$page_id;
}
Thanks for the reply, just to checking $args[‘_page_id’] is pull the current page id? May I know is that anyway we can pull the previous page id? Because I will need to click the result link to redirect back to the previous page.
Yes, that gives the page ID from where the search was initiated. Unfortunately I don’t think that is possible at all. Usually the information is lost during redirection.
There might be a way to somehow get that via server variables, but those probably won’t work in the ajax context. As in that case the previous page (referrer) is actually the page the search is on.