Did you know that WordPress automatically generates a separate page for each image you upload?
These attachment pages often lack meaningful content and can appear broken to visitors. Additionally, search engines might index these pages instead of your valuable posts, negatively impacting your SEO performance.
We remove these unnecessary pages from all our websites to ensure that visitors always access the right content. This simple adjustment can significantly enhance your SEO results.
In this guide, we will demonstrate how to effortlessly disable image attachment pages in WordPress.
Why Should You Disable Image Attachment Pages in WordPress?
By default, WordPress creates an individual page for each media attachment on your site, including images, audio and video files, PDFs, and more.
While some users may find this feature beneficial, the majority of WordPress websites do not require it.
For instance, photographers might appreciate attachment pages. A photography theme could utilize the attachment page to showcase technical EXIF data, displaying details such as the camera model, shutter speed, and aperture settings for fellow photographers.
Many WordPress bloggers unintentionally link their images to attachment pages instead of directly to the images themselves. Additionally, they may find the appearance of these pages unappealing, as many themes lack dedicated templates for image attachment pages.
Occasionally, an image on your website may gain popularity, leading visitors to access the attachment page directly from Google. Ideally, you want these visitors to arrive at your post and view the image within the context you intended.
To address this issue, we will outline two effective methods for disabling image attachment pages in WordPress, allowing you to select the option that suits you best:
- Disabling Image Attachment Pages in WordPress Using a Plugin
- Disabling Image Attachment Pages in WordPress Using a Code Snippet
- Common Questions About Image Attachment Pages
- Further Reading and Resources
Method 1: Disabling Image Attachment Pages in WordPress Using a Plugin
The simplest method to disable image attachment pages is by utilizing the All in One SEO (AIOSEO) plugin. This is the top SEO plugin for WordPress, trusted by over 3 million websites.
First, you need to install and activate the free All in One SEO plugin. For detailed instructions, refer to our guide on installing a WordPress plugin.
After installing and activating the plugin, you will see a new menu item labeled ‘All in One SEO.’
Go to All in One SEO » Search Appearance. Then, click on the ‘Image SEO’ tab.
Ensure that the ‘Redirect Attachment URLs’ option is set to ‘Attachment Parent’. This will automatically redirect users who access an image page to the corresponding article that features that image.
We suggest redirecting to the ‘Attachment Parent’ page. This way, if a user visits the image attachment page, they will be redirected to your article instead.
Important: If an image does not have a parent page (such as a logo uploaded directly to the Media Library), AIOSEO will not be able to redirect it to a post. In this case, it will redirect to the image file itself. Alternatively, you can select ‘Home Page’ in the settings above to direct all attachment traffic to your homepage.
After selecting your desired setting, click ‘Save Changes’ before leaving the page.
Method 2: Disable Image Attachment Pages in WordPress Using a Code Snippet
Another option is to insert a code snippet into WordPress. We do not advise modifying your WordPress files directly, so we will use WPCode for this tutorial.
Begin by installing the free WPCode plugin. For detailed instructions, refer to our guide on installing a WordPress plugin.
After activation, navigate toCode Snippets » Add Snippetin your admin dashboard.
Next, enter ‘attachment’ in the search bar. You should see a snippet labeled ‘Disable Attachment Pages’ on the right.
Hover over it and click the ‘Use Snippet’ button.
You will be directed to the ‘Edit Snippet’ page. WPCode will automatically set up the code and configurations for you, ensuring it specifically targets attachment URLs without impacting the rest of your website.
Simply switch the toggle to ‘Active’ and click the ‘Update’ button.
Now, when a user visits your image attachment page, they will be redirected to the parent post. If the image has no parent post, the user will be redirected to the homepage of your site.
Common Questions About Image Attachment Pages
We understand you may have additional questions regarding this topic. Here are answers to some of the most frequently asked questions from our readers.
1. How does disabling image attachment pages benefit my website’s SEO?
Disabling image attachment pages improves your SEO by eliminating low-value, thin content. Search engines have a limited crawl budget for each website, so you want them to focus on indexing your valuable content rather than empty image pages.
2. Will disabling attachment pages remove my images or affect my website?
No, your images will remain safe in your WordPress media library and will continue to appear in your posts and pages. This process only disables the separate, automatically generated pages for those images. Both methods we outlined are secure and will not disrupt your website.
3. What is the simplest way to disable image attachment pages?
For most users, the easiest solution is to use a plugin like All in One SEO (AIOSEO). It requires no coding skills and provides a straightforward toggle switch to redirect attachment URLs. This method is quick, safe, and ideal for beginners who prefer not to modify code files.
4. What occurs when someone clicks on a link to an old attachment page?
By disabling attachment pages through either method, visitors who access an old URL will be automatically redirected to the relevant post or page containing the image (the parent post). This enhances user experience and prevents potential visitors from landing on a dead-end page.
5. Should I also disable attachment pages for other media types such as videos or PDFs?
Absolutely, we recommend doing so. WordPress generates attachment pages for all types of media uploads, not just images. Disabling these pages for all media formats using the methods outlined in this guide helps maintain a clean site and keeps the focus on your main content, ensuring a consistent user experience and SEO advantages throughout.
Additional Resources
We hope this article has assisted you in disabling image attachment pages in WordPress. You may also find our other guides helpful for enhancing your website’s media management:
- Beginner’s Guide to Image SEO: Optimize Your Images for Search Engines
- How to Resolve Common Image Issues in WordPress
- How to Organize Your WordPress Files in Media Library Folders
- How to Properly Add Images in WordPress: A Step-by-Step Guide
If you enjoyed this article, please subscribe to our YouTube Channel for WordPress video tutorials. You can also connect with us on Twitter and Facebook.



