Skip to content Skip to sidebar

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This topic contains 1 reply, has 0 voices.

Last updated by danielI-23 6 months, 2 weeks ago.

Assisted by: Otto.

Author Posts
October 1, 2025 at 2:41 pm #17449212

danielI-23

Background of the issue:
I am trying to link to various pages and CPT posts in different languages without WPML automatically translating them or changing the URLs to language-appropriate URLs. I have two pages: hidden link and hidden link with exact content on both. On the Croatian page, links remain unchanged, but on the English translation, URLs of the links get mixed up. I want to link to a Croatian page (hidden link), but WPML auto-translates the URL to hidden link. The same issue occurs with links CPT posts, where links are changed to the Croatian version.

Symptoms:
WPML is automatically translating or changing URLs within the page/post/CPT content, even when translations of the posts I am linking to exist. For example, a link to /testiranje-linkova/ is incorrectly changed to hidden link, and a link to /en/osoba/ante-sikirica/ is incorrectly changed to hidden link.

Questions:
Is it possible to prevent WPML from changing URLs within the page/post/CPT content?
How can I maintain original URLs when linking to pages or posts in different languages?

October 1, 2025 at 6:16 pm #17449958

Otto

Hello,

Please take a look at this reply that addresses the same request:
https://wpml.org/forums/topic/turn-off-auto-translation-of-links-in-content/#post-17047383

Best Regards,
Otto

October 2, 2025 at 10:22 am #17451584

danielI-23

Thanks Otto, the link you provided didn't solve my issue out-of-the-box, but it provided guidance which led me to a solution. Here's a summary of the solution for my use case if anyone else should need it.

Problem:
WPML was automatically translating custom post type (CPT) URLs from /en/osoba/post-name/ to /osoba/post-name/, removing the language code.

Solution:
I used the wpml_sl_blacklist_requests filter with proper regex pattern to blacklist all posts under a specific CPT slug.

Working Code:
add_filter( 'wpml_sl_blacklist_requests', 'wpml_sl_blacklist_requests', 10, 2 );

function wpml_sl_blacklist_requests( $blacklist, $sitepress ) {
$blacklist[] = '/osoba\/.*/'; // Replace 'osoba' with your CPT slug
return $blacklist;
}

Key Points:
- Use regex delimiters: /pattern/
- Escape forward slashes in the path: \/
- Do NOT include the language code (e.g., en) in the pattern - WPML strips it before matching (this one added like an hour to my troubleshooting)
- Use .* to match any post slug after your CPT base

This will prevent WPML from translating links for all posts under that CPT, keeping them in their original language.

To blacklist multiple CPTs or pages, simply add more lines:
$blacklist[] = 'single-page-slug';
$blacklist[] = '/another-cpt\/.*/';