• Resolved jmdfrancois

    (@jmdfrancois)


    Hello,

    First of all, thank you for your great plugin!

    I am currently using the extension “Ajax Search Lite” as search bar.

    I would like to know if it is possible to get search results linking directly to the affiliate links of each products, not the product page links?

    For example, for the first product the search result is linking to : mywebsite.com/shop-page/product_page/

    And I would like the search results to go directly to the product affiliate URL.

    Guys from “Ajax Search Lite” tried to help me out, but I would need your help to know what is the exact “affiliate_url” custom field.

    You can find more information here: https://wordpress.org/support/topic/redirection-to-specific-affiliate-link/

    Thank you for your help and your great work!

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author leonmagee

    (@leonmagee)

    Hi @jmdfrancois, I’m not entirely sure if this is doable, but I’ll do some testing to find out.

    Plugin Author leonmagee

    (@leonmagee)

    @jmdfrancois I was able to get this working. Here’s the updated code:

    add_filter('asl_results', 'my_custom_link_asl_results', 10, 1);
    function my_custom_link_asl_results($results)
    {
        foreach ($results as $k => &$r) {
            $link = get_post_meta($r->id, '_Shop_Page_WP_url', true);
            if ($link != '') {
                $r->link = $link;
            }
        }
        return $results;
    }

    Note that I changed the ID passed into get_post_meta in addition to the name of the custom field.

    You’ll need to add this code to your theme’s functions.php file, and also enable the Shop Page WP custom post type in the Ajax Search Lite settings.

    Please let me know if this works for you.

    Does this work only for Ajax Search Lite? or something similar can be done also for WordPress Search block?

    Plugin Author leonmagee

    (@leonmagee)

    @tomitzu This code is specific for Ajax Search Lite. I’ll take a look at the search block and see if something similar can be done.

    Plugin Contributor Justin McChesney-Wachs

    (@justinmw)

    Closing out this ticket. Please open a new one if you need further assistance

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Search bar redirection to specific affiliate link’ is closed to new replies.