This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Reply To: Custom URL for Results

#45470
adam-polyaire89adam-polyaire89
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;
}