Use a filter for wp_robots to block CPT/feed/
We have a CPT (with base slug templates
) that somehow included in every single post's head a link to /templates/post/feed/
.
I've removed this link to the feed from the head, but want to block robots from the feed also.
From this answer, I can adapt code like:
add_filter( 'wp_robots', function( $robots ) {
if ( is_singular( 'templates' ) ) {
$robots['noindex'] = true;
$robots['nofollow'] = true;
}
return $robots;
} );
but don't know how to include is_feed() into this code.
Would I use something like if ( is_singular( 'templates' ) is_feed( 'templates' ) )
?
Help appreciated.
EDIT
Alternatively, I could somehow add the following to robots.txt
:
User-agent: *
Disallow: /templates/*/feed
but do not know the function/hook to do this. We're using Yoast SEO
.
Help appreciated.
Topic robots.txt functions feed Wordpress
Category Web