add_filter('wpml_ls_language_url', 'redirect_link',10,2);
function redirect_link($url,$lang){
if($lang['missing'] == 1) {
$permalink_to_translation_not_found_page_in_main_language = get_the_permalink(40); //40 is page id of a custom translation not found page in main language
$lang['url'] = apply_filters( 'wpml_permalink', $permalink_to_translation_not_found_page_in_main_language , $lang['language_code'] );
}
return $lang['url'];
}
1 回答
首先确保您已选中WPML->语言 - >语言切换器选项“链接到缺少翻译的语言的家” . 然后使用主要语言创建自定义翻译未找到页面,并使用WPML将其翻译为其他语言 . 然后将此代码添加到functions.php中
我希望这对某人有用