Create affiliate url for current page

Hey @garrretts,

Thank you for reaching out! From what I see, the code you’ve shared is working correctly. It returns the referral link for affiliate with ID 10.

For a complete shortcode code, please add this snippet:

function slicewp_custom_current_page_referral_link() {
	
	global $wp;

	$current_url  = home_url( add_query_arg(array(), $wp->request) );
	$referal_link = slicewp_get_affiliate_url( 10 , $current_url );
	
	return ( $referal_link ? $referal_link : '' );
	
}
add_shortcode( 'slicewp_custom_current_page_referral_link', 'slicewp_custom_current_page_referral_link' );

Then, you can use the “[slicewp_custom_current_page_referral_link]” shortcode in your website. It will output the current page’s URL as a referral link for affiliate with the ID 10.

To have the code output the referral link for the currently logged-in affiliate, replace the “10” string from your code with this function: slicewp_get_current_affiliate_id()

The function will return the current affiliate’s unique ID.

Thank you and best wishes,

Mihai

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer