admin管理员组文章数量:1297134
I want add WordPress post tags in meta property="article:tag"
.
Something like this:
This site is optimized with the Yoast WordPress SEO plugin v1.4.25
meta name="robots" content="noodp,noydir"
meta name="robots" content="noodp,noydir"
meta name="description" content="Download last music"
meta property="og:type" content="article"
meta property="og:title" content="download new music"
meta property="article:tag" content="test2"
meta property="article:tag" content="test3"
meta property="article:tag" content="test4"
meta property="article:section" content="download"
meta property="article:section" content="download music"
meta property="article:published_time" content="2014-03-11T21:42:57+00:00"
meta name="twitter:card" content="summary"
/ Yoast WordPress SEO plugin.
test2,test3,test4 are my post tags.
I want add WordPress post tags in meta property="article:tag"
.
Something like this:
This site is optimized with the Yoast WordPress SEO plugin v1.4.25
meta name="robots" content="noodp,noydir"
meta name="robots" content="noodp,noydir"
meta name="description" content="Download last music"
meta property="og:type" content="article"
meta property="og:title" content="download new music"
meta property="article:tag" content="test2"
meta property="article:tag" content="test3"
meta property="article:tag" content="test4"
meta property="article:section" content="download"
meta property="article:section" content="download music"
meta property="article:published_time" content="2014-03-11T21:42:57+00:00"
meta name="twitter:card" content="summary"
/ Yoast WordPress SEO plugin.
test2,test3,test4 are my post tags.
Share Improve this question edited Mar 13, 2014 at 17:18 Dan 8971 gold badge10 silver badges26 bronze badges asked Mar 13, 2014 at 16:36 alirezaalireza 1091 bronze badge 1- yes , but i can't do that. – alireza Commented Mar 13, 2014 at 19:58
1 Answer
Reset to default 0Since you are you using Yoast WordPress SEO plugin you can utilize its hook action wpseo_opengraph
to add your custom meta tag property.
Add the following code to your theme functions.php file:
function wpse213_article_tag(){
global $post;
if($post->post_type == 'post') {
if($tags = get_the_tags($post->ID)) {
foreach($tags as $tag) {
echo '<meta property="article:tag" content="' . esc_attr($tag->name) . '" />' . "\n";
}
}
}
}
add_action( 'wpseo_opengraph', 'wpse213_article_tag', 10 );
本文标签: How can I add meta tags in the WordPress header
版权声明:本文标题:How can I add meta tags in the WordPress header? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741647340a2390264.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论