admin管理员组文章数量:1130349
I want to add a meta data in the head of my website.
I have a post type with custom template : single-custom.php
In this template, I want to add this meta : <meta name="robots" content="noindex"> considering some variable.
I collect number of post related to the current post... I use :
// if less than 6 related posts, add meta
if (count($posts) < 6) {
add_action( 'wp_head', 'noindex_meta' );
}
And in my functions.php :
// add noindex meta to head
function noindex_meta() {
echo '<meta name="robots" content="noindex">';
}
But it doesn't work, it works if I call add_action(...) in my functions.php, but not in theme template.
Is it possible ?
I want to add a meta data in the head of my website.
I have a post type with custom template : single-custom.php
In this template, I want to add this meta : <meta name="robots" content="noindex"> considering some variable.
I collect number of post related to the current post... I use :
// if less than 6 related posts, add meta
if (count($posts) < 6) {
add_action( 'wp_head', 'noindex_meta' );
}
And in my functions.php :
// add noindex meta to head
function noindex_meta() {
echo '<meta name="robots" content="noindex">';
}
But it doesn't work, it works if I call add_action(...) in my functions.php, but not in theme template.
Is it possible ?
本文标签: functionsAdd meta data in head from theme
版权声明:本文标题:functions - Add meta data in head from theme 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749229940a2336311.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论