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.
From WPML 5.1, such links show as text without a link. The cause is in WordPress: when a post type and a taxonomy share a slug, WordPress gives that address to only one of them. If the taxonomy is registered first, the post’s address returns a 404 error even without WPML.
Workaround
Give the custom post type and the taxonomy different slugs, in ACFPost Types and ACFTaxonomies or in the code that registers them. Then go to SettingsPermalinks and click Save Changes.
If you use WPML 5.0 or older, you can also add this snippet to your functions.php file. From WPML 5.1 on, it has no effect.
/**
* Temporary snippet: Replaces relative links with absolute links
* before it get converted by the filter `wpml_translate_link_targets`.
*/
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 );Need Help with This Issue?
Ask a support question and we’ll look into it with you.
Ask a support question