Custom URL on filter results

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Custom URL on filter results

This topic contains 7 replies, has 2 voices, and was last updated by Ernest Marcinko Ernest Marcinko 4 years, 5 months ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #24326
    therainbowmash41
    therainbowmash41
    Participant

    I am using Ajax Search Pro to filter my Avada portfolio results – the plugin is great but I have a requirement which Ernest Marcinko said you should be able to do.

    I have been speaking to Ernest about enabling the user being able to click through to a custom URL (that has been defined in the portfolio page). This custom URL works if I use Avadas filters (which aren’t great) but ASP blocks the assigned custom URL and defaults back to taking the user to portfolio page URL (which my client doesn’t want).

    Avada have supplied me with the wrapper code for the custom url (attached).

    This is the portfolio results page:
    http://develop1.therainbowmash.co.uk/escape-rooms/

    Attachments:
    You must be logged in to view attached files.
    #24336
    Ernest Marcinko
    Ernest 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;
    }
    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #24339
    therainbowmash41
    therainbowmash41
    Participant

    HI Ernest

    Thank you very much this si great! I really appreciate it!

    I have duplicated the functions.php file and stored safely.

    Do I need to replace the functions.php file with your amended version after every Avada update or is it better to paste the code into the updated functions.php file?

    Ideally I would have created a child theme initially but I don’t want to lose all the work I have done up to this point.

    Thanks

    #24344
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    It will be probably lost during the theme update. A child theme would be the only solution to keep the changes. Until then, you can re-enter the code to the functions.php file after each theme update if needed.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #24349
    therainbowmash41
    therainbowmash41
    Participant

    Thanks very much for your help!

    #24350
    Ernest Marcinko
    Ernest Marcinko
    Keymaster
    You cannot access this content. Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #24352
    therainbowmash41
    therainbowmash41
    Participant

    I have reviewed and give 5 stars!

    One thing actually – is there an ability to have just the filter drop down menus without the search bar? And have the drop downs on screen at all times?

    Thanks

    Chris

    #24353
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Thank you very much 🙂

    Yes, this is the option you are looking for: https://i.imgur.com/hpjgupL.png

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


Viewing 8 posts - 1 through 8 (of 8 total)

The topic ‘Custom URL on filter results’ is closed to new replies.