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

Reply To: Custom URL on filter results

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