Delete page from attached file in WordPress

How to delete “attachment file pages” on WordPress?
On WordPress, images uploaded to the media library each have a reference page called the “attachment file page” containing only that image.

This page is created automatically by WordPress, so you may end up with a long list of indexed pages whose usefulness is highly questionable, which is why I propose a solution to delete these pages.

Here’s a simple solution to delete these unwanted pages.
Create an image.php page in your child theme and paste the following code into it:

If you do not want to remove access to these pages but simply prevent their indexing, the Yoast SEO plugin allows you to add a meta noindex on these pages.

yoast-seo-titres-et-metas
Yoast Seo / Titles and Metas

 

Save

Save

Save

Save