Home › Forums › Product Support Forums › Ajax Search Pro for WordPress Support › Custom URL on filter results › Reply To: Custom URL on filter results
October 15, 2019 at 1:35 pm
#24336
Keymaster
Hi,
Thank you for all the details, I have managed to find the link sources. It was not exactly what the Avada team sent, but the link was stored in the “pyre_link_icon_url” custom field.
I have constructed a small custom code snippet to replace the link URLs, where this custom field is defined. I have placed the following custom code to the functions.php file in your theme directory, please keep a copy of it just in case. It should be all right now.
// AJAX SEARCH PRO SPECIFIC
add_filter( 'asp_results', 'asp_custom_link_meta_results', 10, 1 );
function asp_custom_link_meta_results( $results ) {
// Change this variable to whatever meta key you are using
$key = 'pyre_link_icon_url';
// Parse through each result item
foreach ($results as $k=>$v) {
if ( function_exists('get_field') )
$new_url = get_field( $key, $v->id, true ); // ACF support
else
$new_url = get_post_meta( $v->id, $key, true );
// Change only, if the meta is specified
if ( !empty($new_url) ) {
$results[$k]->link = $new_url;
}
}
return $results;
}