WordPress SEO by Yoastの設定した項目を表示する
2014-09-19
WordPressでSEOプラグインといえば「WordPress SEO by Yoast」ですが、各記事で設定した内容をテーマで取得・表示したい時は以下の方法で可能です。
このプラグインの素晴らしいところは、各項目・内容がカスタムフィールドに格納されているので、カスタムフィールド名さえ判れば、普通の方法で取得できる点ですね。
get_post_meta(get_the_ID(), '##取得したい項目のフィールド名##', true);
WordPress SEO by Yoast フィールド名
Focus Keyword | _yoast_wpseo_focuskw |
SEOタイトル | _yoast_wpseo_title |
Meta Description | _yoast_wpseo_metadesc |
SEOキーワード | _yoast_wpseo_metakeywords |
Meta Robots Index | _yoast_wpseo_meta-robots-noindex |
Meta Robots Follow | _yoast_wpseo_meta-robots-nofollow |
Meta Robots Advanced | _yoast_wpseo_meta-robots-adv |
Breadcrumbs title | _yoast_wpseo_bctitle |
Include in Sitemap | _yoast_wpseo_sitemap-include |
Sitemap Priority | _yoast_wpseo_sitemap-prio |
Include in HTML Sitemap | _yoast_wpseo_sitemap-html-include |
Canonical URL | _yoast_wpseo_canonical |
301 Redirect | _yoast_wpseo_redirect |
Facebook Description | _yoast_wpseo_opengraph-description |
Google+ Description | _yoast_wpseo_google-plus-description |