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 1:59 am
#45470
Participant
thank you, is it possible to change this, code so that it only applies to 1 Ajax search, eg, just [wd_asp id=2]?
// 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';
// --- DO NOT CHANGE ANYTHING BELOW ---
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;
}