Open
Reported for: WPML Multilingual CMS 4.6.13
Overview of the issue
There’s a known issue where relative links display incorrectly in WYSIWYG fields when a Custom Post Type and a Taxonomy share the same slug. This causes the links to revert to a query string format on the frontend, diverging from the expected pretty permalink structure.
For example, a link that should lead to http://domain/test/post-type/test-cpt/, points to http://domain/?taxonomy-test-post-type=test-cpt instead.
Workaround
You can add this snippet to your functions.php file:
/**
* Temporary snippet: Replaces relative links with absolute links
* before it get converted by the filter `wpml_translate_link_targets`.
*
* @see https://onthegosystems.myjetbrains.com/youtrack/issue/wpmldev-3478
*/
add_filter( 'wpml_translate_link_targets', function( $value ) {
return preg_replace_callback( '/href="([^"]+)"/i', function( $matches ) {
if ( false === strpos( $matches[1], '://' ) ) {
$url = site_url( $matches[1] );
} else {
$url = $matches[1];
}
return 'href="' . $url . '"';
}, $value );
}, 0 );