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

Reply To: Custom URL for Results

#45472
Ernest MarcinkoErnest Marcinko
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;
}