- ステータス
- 未解決
- 報告対象
- WPML SEO 2.1.1
- 関連するプラグイン/テーマ
- Yoast SEO
- トピックタグ
- Compatibility
問題の概要
Yoast SEOを使用する場合、プラグインは著者アーカイブページのheadセクションにOpen Graphメタタグを自動的に追加します。しかし、翻訳された著者アーカイブページでは、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 );