Winter Special Sale! Unlock a 20% OFF on Bundle of 240+ WP Themes & 5 Plugins. Use code "SNOW20"
This Winter, Enjoy a cozy 25% discount on Premium WordPress Themes with the coupon code "WINTER25" at Checkout.

How You Can Disable Image Attachment Pages in WordPress

In WordPress, attachment pages are not so known or understood by many of the users. An attachment page is basically a dedicated page created automatically by WordPress. It is created every time you upload any media file like an image, video, audio, etc. For every media file, a separate page is created. Have you observed that whenever you click on an image on any website, that particular image opens up as a web page, right? This is exactly what an image attachment page is. In this blog, we shall see how to disable image attachment pages in WordPress.

Share:

Do you Think That Image Attachment Pages are Useful?

disable-image-attachment-pages-in-wordpress

If you ask my opinion, image attachment pages are literally a waste of space since having a single page for every attachment engages the memory unnecessarily. And this is not just the case with image attachments. This is so true for other attachments that come in audio or video format, PDFs, docs, and more.

Every time a user clicks on the attachment, a different page solely displaying that particular attachment gets open and that looks very ugly as many of the WP themes do not include the templates for such a kind of situation. Apart from this, there lies a bigger problem with such image attachment pages as most people are unaware of it. Protecting your pages or posts against cyberattacks can be done using encryption and this is what most web developers focus on. However, the media attachment or image attachment pages may serve as a backdoor for the hackers to peek in as they contain important info that any website owner would never like to disclose to the public.

The good news is you can deal with this problem in two ways. You can either disable image attachment pages in WordPress or you can redirect.

Why Disable Image Attachment Pages in WordPress?

Like I said earlier, attachment pages contain vital information and if these pages are accessible, there is a strong possibility of your information being stolen. So, you need to hide these pages for ensuring that those pages are only accessible to the granted users. For hiding those pages, connect the FTP software to the website server and locate file image.php. Add some code to it. If you do not find the file or if the file is unavailable, you can create one then write the code and upload it in the root directory. What it does is if any person tries to access the image, that person will get directed to the homepage. But if you are not comfortable with codes, there is another way. You can use plugins to disable image attachment pages in WordPress.

Using Yoast SEO Plugin

Yoast SEO plugin is an excellent plugin with tools for managing the appearance of your site in search engines. It has tools to handle a redirect for image attachment pages or media URLs. Once you install and activate this plugin, follow these steps:

  • From the WordPress dashboard, go to SEO and click on ‘Search Appearance”.
  • Hit the ‘Media” tab.
  • Click on the ‘Yes’ button which is under the Media and Attachment URLs. with this, the media URLs will be set to get redirected to the file itself instead of creating any additional page on the website.
  • The SEO options in Yoast will be removed for these file attachment pages.
  • Click on the ‘Save Changes’ option and it’s done.

Using Attachment Pages Redirect

This Attachment Pages WordPress Redirect plugin is a fine tool that creates redirects depending upon how a user lands on your attachment page.

This is how it works: For example, a 302 redirect to the homepage will be created by the plugin if your original post lies in the trash. However, the users will still be able to access your website through the image URL or the file URL. In short it means that there will be no 404 file not found error displayed to the user.

Once you install and activate the ‘Attachment Pages Redirect’ plugin, it will begin redirecting the users automatically. There are hardly any settings or setting options available for managing it.

So, here we saw how to disable image attachment pages in WordPress. We are developers and we offer professional WordPress themes. You can purchase our WP theme bundle at a very low price from our website. Check it out!

Share: