Answer the question
In order to leave comments, you need to log in
How to disable indexing of individual pages for attachment wordpress?
There is a page, attachments (pictures) are loaded for it. And these attachments were indexed in Google, getting a separate page each. Can you please tell me how to delete the pages of these attachments and disable their indexing? Is it enough to write in robots.txt a ban on indexing wp-content/uploads?
Answer the question
In order to leave comments, you need to log in
SEO plugins have a setting - redirect to a post.
This is better than 404.
In general, in order to avoid this, it was not necessary to make links to attachment pages when inserting pictures.
paste in functions.php
function wph_noindex_for_attachment() {
if(get_post_mime_type()!= false) {
echo '<meta name="robots" content="noindex, nofollow" />'.PHP_EOL;
}
}
add_action('wp_head', 'wph_noindex_for_attachment');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question