• Resolved Graydon Schwartz

    (@graydonschwartz)


    Hello TranslatePress Support,

    I’m currently experiencing a challenge with the TranslatePress plugin on my WordPress site and I’m hoping to find some guidance or solutions from the community.

    Issue Description:

    TranslatePress automatically adds a language prefix (like /de/) to all URLs on my site. While this is generally useful for most pages, it’s problematic for my affiliate links. For instance, an affiliate link that should be https://graydonschwartz.com/recommends/tesbeauty/ is being changed to https://graydonschwartz.com/de/recommends/tesbeauty/. This alteration is not desirable for these specific links.

    Example of the Issue:

    Attempts to Resolve:

    I’ve tried various settings within TranslatePress and looked for plugins or code snippets that might address this issue, but so far, I haven’t had any success. The main goal is to exclude the language prefix from specific URLs (in this case, affiliate links) while keeping it functional for the rest of the site.

    Seeking Suggestions:

    Any advice, tips, or guidance on how to resolve this issue would be immensely appreciated. If anyone has faced a similar problem or knows how to configure TranslatePress to exclude certain URLs from having the language prefix added, your input would be invaluable.

    Thank you so much for taking the time to read my post. I look forward to any suggestions or solutions you might have.

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

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hello there,

    Thanks for reaching out to us!

    We have in place a custom code that you can use in order to sort this out.

    /*
     * Do not translate URL's containing a certain path in them.
     */
    add_filter( 'trp_get_url_for_language', 'trpc_do_not_translate_go_links', 10, 6);
    function trpc_do_not_translate_go_links($new_url, $url, $language, $abs_home, $lang_from_url_string, $lang_url_slug){
    	if( str_contains( $url, '/go/' ) ){
    		return $url;
    	}
    }

    Just replace /go/ with your own affiliate link.

    Let me know if it works.

    Best Regards,

    Thread Starter Graydon Schwartz

    (@graydonschwartz)

    Good morning, I’m still facing challenge with affiliate links on my website. I cleared browser cache and site cache as the first step in troubleshooting but the fault still exists.

    I tried inserting the provided function into a new WordPress plugin and before I tried the functions.php file of my child theme.

    Can you tell me if there are particular settings or caches within TranslatePress that I should have a look at or delete?

    Hello there,

    We deeply apologize for the delayed response.

    There has been a great load on our support team in the past few days, but such a long reply time is very uncommon.

    If this method did not work for you I am afraid there isn’t much we can do.

    Maybe you can find a suitable method that might work for you here.

    Thank you for understanding and for your patience!

    Plugin Support Anghel Emanuel

    (@anghelemanuel99)

    Hello there,

    Since 5 days have already passed without getting any reply from you, I will mark this thread as “Resolved”.

    If you have another problems, do not hesitate to open a new thread!

    Kind Regards,

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Exclude Affiliate Links’ is closed to new replies.