• jmdfrancois

    (@jmdfrancois)


    Hello,

    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?

    I am using the extension “Shop Page WP” which gives the option to get affiliate links for each products: https://i.imgur.com/vCRzrRi.png

    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

    I imagine I can find a way to manage this in the “Trigger and redirection behavior” section of “Ajax Search Lite”, but I couldn’t find it yet.

    Thank you for your help and your great work!

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

Viewing 1 replies (of 1 total)
  • Plugin Author wpdreams

    (@wpdreams)

    Hi!

    This should be doable, but requires a bit of custom code.

    I am more than happy to help you with that. I assume that the affiliate link is probably in a custom field called “affiliate_url”.

    Try adding this code to the functions.php file in your theme/child theme directory – make sure to have a full server back-up first for safety. For more details you can check the safe coding guidelines.

    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($post->ID, 'affiliate_url', true);
    		if ( $link != '' ) {
    			$r->link = $link;
    		}
    	}
    	return $results;
    }

    If this does not work, then the link might be stored differently.

    Best,
    Ernest M.

Viewing 1 replies (of 1 total)
  • The topic ‘Redirection to specific affiliate link’ is closed to new replies.