WPML
状态
未解决
报告针对
WPML Multilingual CMS 4.6.13
主题标签
Bug

问题概述

存在一个已知问题:当自定义文章类型分类法共享相同的别名时,相对链接在 WYSIWYG 字段中会显示不正确。这会导致链接在前端回退到查询字符串格式,与预期的美观固定链接结构不符。

例如,原本应指向 http://domain/test/post-type/test-cpt/ 的链接,却指向了 http://domain/?taxonomy-test-post-type=test-cpt

临时解决方法

您可以将此代码片段添加到 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 );

所有已知问题 →