admin管理员组文章数量:1122847
I am using the following snippet in my functions.php.
function add_noindex() {
if(is_archive()) {
echo '<meta name="robots" content="noindex,follow" />';
}
}
add_action( 'wp_head', 'add_noindex' );
I thought this would noindex all my archive pages, but it is not working. My archive page code looks like this:
<?php get_header(); ?>
<h1><?php single_cat_title();?></h1>
<?php if (have_posts()) : while(have_posts()) : the_post();?>
<h3><?php the_title();?></h3>
<?php the_excerpt();?>
<a href="<?php the_permalink();?>">Read More</a>
<?php endwhile;
endif;?>
Any ideas? Thank you in advance!
I am using the following snippet in my functions.php.
function add_noindex() {
if(is_archive()) {
echo '<meta name="robots" content="noindex,follow" />';
}
}
add_action( 'wp_head', 'add_noindex' );
I thought this would noindex all my archive pages, but it is not working. My archive page code looks like this:
<?php get_header(); ?>
<h1><?php single_cat_title();?></h1>
<?php if (have_posts()) : while(have_posts()) : the_post();?>
<h3><?php the_title();?></h3>
<?php the_excerpt();?>
<a href="<?php the_permalink();?>">Read More</a>
<?php endwhile;
endif;?>
Any ideas? Thank you in advance!
Share Improve this question asked Jul 22, 2020 at 14:00 Summer PrattSummer Pratt 11 Answer
Reset to default 0This worked ok for me, putting this function into a vanilla build using TwentyTwenty? I see the output in the Head.
Its very crude but inside your IF statement, add some form of simple debug, either var_dump() a string out or Javascript console.log. You're testing to make sure the IF is activating when you think it is. Also consider using the Show Current Template plugin as this would highlight if you weren't using the template you expected to when visiting the page.
本文标签: seoHow can I noindex my archive pages
版权声明:本文标题:seo - How can I noindex my archive pages? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736291302a1928695.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论