Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Custom URL for Results › Reply To: Custom URL for Results
September 21, 2023 at 9:54 am
#45472
Keymaster
Yes, of course 🙂
Here you go:
// Remove the line below, if you don't want to affect the Live results list
add_filter( 'asp_results', 'asp_custom_link_results', 10, 4 );
// Remove the line below, if you don't want to affect the results page
add_filter( 'asp_noajax_results', 'asp_custom_link_results', 10, 4 );
function asp_custom_link_results( $results, $search_id, $is_ajax, $args ) {
// Replaces each result URL with this
$replace_with = 'https://google.com';
$apply_to_search_ids = array(2); // Search IDs to apply the code to
// --- DO NOT CHANGE ANYTHING BELOW ---
if ( in_array($search_id, $apply_to_search_ids) ) {
foreach ($results as $k=>&$r) {
// Ajax results link
if ( isset($r->link) ) {
$r->link = $replace_with;
}
// Results page link
if ( isset($r->asp_guid) ) {
$r->asp_guid = $replace_with;
}
}
}
return $results;
}