January 10, 2018
WordPress has so many different “stock” template types that are not used on every type of website. For example, a small business website, may not use the Archive, Blog or Single page layouts.
In my seven years of building WordPress website, I have yet to come across a single client that uses the “Attachment Page” layout (properly, at least).
Yet, when inserting Media items into content, it’s one of the available options:
If there’s a way to remove this option from WordPress core, I would love to know about it. Please leave me a comment.
In the meantime, to disable access to this file type, create a file called image.php in your Theme folder and paste the following into it:
<?php wp_redirect(get_permalink($post->post_parent)); ?>