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