问题概述
在Google Analytics for WordPress by MonsterInsights中,翻译页面上的“热门文章”列表会显示其他语言的文章。例如,西班牙语页面的访客会看到指向英语文章的链接。
临时解决方法
在 MonsterInsights 修复此问题之前,请将以下代码添加到主题的 functions.php 文件中,或使用代码片段插件添加。这样,热门文章将列出当前语言的文章。
add_filter( 'monsterinsights_popular_posts_query_args', function ( $args ) {
$args['suppress_filters'] = false;
$args['lang'] = apply_filters( 'wpml_current_language', null );
return $args;
} );