- 状态
- 未解决
- 报告针对
- WPML SEO 2.1.1
- 相关插件/主题
- Yoast SEO
- 主题标签
- Compatibility
问题概述
使用 Yoast SEO 时,插件会自动将 Open Graph 元标签添加到作者归档页面的 head 部分。但是,在翻译后的作者归档页面上,og:url 元标签将显示默认语言的 URL。
临时解决方法
在继续操作之前,请确保拥有完整的站点备份。
- 打开您主题的 functions.php 文件。
/** * Workaround to fix og:url meta tag on translations of author archives */ add_filter( 'wpseo_opengraph_url', function($url, $presentation){ if ( $presentation instanceof YoastWPSEOPresentationsIndexable_Author_Archive_Presentation ){ $user_id = $presentation->source['post_author']; $url = rawurlencode( get_author_posts_url($user_id) ); } return $url; }, 10, 2 );