Recently we discovered that when adding embedded URLs in the post body referring to the same post but in another language (we have a bilingual site Dutch-English, but not all content is translated as not always applicable), the URL's are overwritten when saving (not when previewing the changes).
The misbehavior looks similar to https://wpml.org/forums/topic/wpml-french-redirect-bug-full-debugging-summary/ but playing with the WPML Sticky Link renders the URL human-unreadable (?p=...). The ?p=... URL points the correct page, but when accessing it from the front-end, it is rewritten somewhere else again to the wrong one.
My question is: how do I prevent inline URL's to be rewritten? If I decide to add an URL manually, I don't want it to be overruled.
As I understand it, you are manually inserting links to a page in another language. In this case, WPML will automatically adjust those URLs, which is why your manual links are being overwritten.
To prevent this behavior, you can exclude specific links from being rewritten. This can be done by blacklisting certain slugs so WPML does not modify them.
Thanks for getting back to me.
Due to holidays, I wasn't able to respond earlier.
Your suggestion to exclude specific links by blacklisting certain slugs doesn't really make sense to me as I would have to exclude all: when we add an URL pointing to the same event in the other language, we do that deliberately as our events are in most cases one-language only.
So if I could exclude events only (by adding 'event' to the blacklist), I think that could do (for now).
Can you confirm that would do it? I've added the WPML Sticky Links to a staging environment and things went quite terribly wrong (URL's replaced with ?p=...).
Thanks for getting back to me, and no worries at all.
Regarding your idea excluding all events by adding something like “event” to the blacklist in theory that could help limit the behavior.
Also, just to clarify: I would not recommend using the Sticky Links add-on in your case. What you experienced (URLs being replaced with ?p=… format) is expected behavior for that plugin, and it’s generally not suitable for setups like yours.
From WPML’s perspective, it’s designed to use the correct language-specific URLs and their translations. Manually linking to content in a different language (as you’re doing for one-language events) is a more custom use case and not something WPML handles out of the box.
If this affects many URLs, the best approach would be to handle it via a small custom code adjustment tailored to your logic (e.g. conditionally preventing URL rewriting for specific post types like events).
Based on the example of danielI-23 you're referring to, I was able to fix this.
I've added the following in the theme's functions.php file:
if (!function_exists('wpml_sl_blacklist_requests')):
/**
* Prevent slug to be translated behind the scenes by WPML
*/
function wpml_sl_blacklist_requests( $blacklist, $sitepress )
{
$blacklist[] = '/event\/.*/';
$blacklist[] = '/downloads\/.*/';