- Stato
- Aperto
- Segnalato per
- WPML Multilingual CMS 4.6.13
- Tag dell’argomento
- Bug
Panoramica del problema
Esiste un problema noto per cui i link relativi vengono visualizzati in modo errato nei campi WYSIWYG quando un Tipo di post personalizzato e una Tassonomia condividono lo stesso slug. Ciò fa sì che i link tornino a un formato di stringa di query sul frontend, discostandosi dalla struttura prevista dei permalink.
Ad esempio, un link che dovrebbe portare a http://domain/test/post-type/test-cpt/, punta invece a http://domain/?taxonomy-test-post-type=test-cpt.
Soluzione alternativa
Puoi aggiungere questo snippet al tuo file functions.php:
/**
* 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 );