Hey there! If you‘ve been working with WordPress for a while, you‘ve probably noticed that every time you upload an image, WordPress creates a separate attachment page for it.
While this default behavior may seem harmless, attachment pages can actually cause some SEO and user experience issues if you‘re not careful. In this ultimate guide, I‘ll break down exactly what image attachment pages are, why you might want to disable them, and provide two methods for getting rid of them on your WordPress site.
What Are WordPress Image Attachment Pages?
First, let‘s make sure we‘re on the same page about what image attachment pages are. When you upload an image to your WordPress Media Library, either directly or while creating a post or page, WordPress automatically generates a unique page URL for that image.
For example, if you upload an image file named "cute-puppy.jpg" to a blog post at yoursite.com/best-dog-toys/, the attachment page URL would be:
yoursite.com/best-dog-toys/cute-puppy/
If a user clicks on the image file link, they‘ll be taken to this attachment page displaying the full-size image, along with any metadata like the image title, caption, description, and comments. The page will also include navigation links to the previous and next image attachments.
How Many Attachment Pages Are Created?
The average WordPress site has a lot of images, which means a lot of attachment pages get generated. According to a 2022 study by WP Rocket, the median number of images per page is 17 for mobile and 21 for desktop.
Another analysis by WP Beginner found that "the average WordPress site has 412 images. A photography or portfolio site averages over 1,000 images. We have seen eCommerce sites with over 10,000 images."
So if you have even just 100 blog posts with 10 images each, that‘s 1,000 attachment pages created in addition to your core content!
SEO Impact of Attachment Pages
So what‘s the big deal with having all these extra pages? While attachment pages may be useful in some cases, which I‘ll cover later, they often do more harm than good for your WordPress SEO.
One issue is that attachment pages are considered thin content since they typically only contain the image and maybe a brief caption. Google‘s John Mueller has stated that "if it‘s just an image and no textual content at all, then it‘s always going to rank lower than any textual content page."
Attachment pages can also cause duplicate content issues. Since the image file and alt text often appear on both the attachment page and the parent page, Google may view it as duplicate content and not know which page to rank. As Yoast explains:
"In most cases, the image attachment page doesn‘t contain valuable content. Because of that, the link equity of the attachment page is of no real value to your website. That‘s why it makes sense to redirect the attachment page to the wordpress url connected to the image."
In addition to low-value content, attachment pages also waste "crawl budget". This refers to the number of pages Google will crawl on your site in a given period of time. If you have thousands of attachment pages, Googlebot may spend time indexing those instead of your important pages.
Finally, attachment pages provide a poor user experience in most cases. If a user lands on an attachment page from an external link or image search, they won‘t have the context of the referring page. Most will bounce away rather than trying to figure out what the lonely image relates to.
Ok, now that you understand the potential issues with attachment pages and why you may want to disable them, let‘s look at how to actually do it.
Method 1: Disable Attachment Pages Using All in One SEO Plugin
The simplest way to disable image attachment pages in WordPress is by using the All in One SEO (AIOSEO) plugin. This popular SEO toolkit has over 3 million active installations.
Here‘s how to use AIOSEO to redirect attachment pages:
Install and activate the free All in One SEO plugin.
From your WordPress dashboard, go to All in One SEO → Search Appearance.
Click on the Image SEO tab.
Under "Attachment URLs", select Redirect to Parent Post. This will automatically redirect any attachment page URLs to the parent post or page.
Click Save Changes.

That‘s it! Now when a user clicks on an image attachment link, they‘ll be redirected to the original post or page where the image appears. This keeps them on your site and provides the proper context for the image.
If for some reason you‘d prefer to redirect attachment pages to the image file itself rather than the parent page, you can select Redirect to Attachment instead. Keep in mind this will display the raw image file without any surrounding context.
Method 2: Disable Attachment Pages Using Code Snippets Plugin
If you‘d rather not use a full SEO plugin to handle attachment pages, you can achieve the same result with a few lines of code.
I‘ll show you how to add the necessary code using the free Code Snippets plugin. This is safer than editing your theme files directly, as the code will be separate and unaffected by theme updates.
Here are the steps:
Install and activate the Code Snippets plugin.
From your WordPress dashboard, go to Snippets → Add New.
Give your snippet a name like "Disable Attachment Pages".
Paste the following code into the snippet content area:
function redirect_attachment_pages() {
if ( is_attachment() ) {
global $post;
if ( $post && $post->post_parent ) {
wp_redirect( esc_url( get_permalink( $post->post_parent ) ), 301 );
exit;
} else {
wp_redirect( esc_url( home_url( ‘/‘ ) ), 301 );
exit;
}
}
}
add_action( ‘template_redirect‘, ‘redirect_attachment_pages‘ );This code checks if the current page is an attachment. If so, it redirects to the parent post/page if one exists, or to the homepage if there is no parent.
- Click Save Changes and Activate.

With the code snippet active, your WordPress site will now redirect attachment page requests to the appropriate post, page, or homepage.
What Happens to Existing Attachment Page Links?
If your site has been around for a while, you may have accumulated some external links pointing to attachment pages. Once you disable attachment pages, those links will now redirect to either the parent page or homepage, depending on the method you chose.
In most cases, redirecting to the parent page is preferable because it at least keeps the user on your site. But if the external site was specifically linking to the image file as a standalone resource, the parent page may not be a relevant substitute.
As WP Rocket notes: "If you redirect your image attachment URLs to your latest posts page, you might irritate users because the image they wanted to see is not there."
To avoid this, it‘s best to disable attachment pages as early as possible before attracting many external links. If you do have existing attachment page links, try reaching out to the external site owners and ask them to update the URL.
You can find any pages linking to your images using a tool like Ahrefs or Google Search Console.
When to Keep Attachment Pages Enabled
While most WordPress sites are better off without attachment pages, there are some exceptions where keeping them enabled makes sense:
Photography websites – If you run a photography site and want to provide additional info about your images like camera settings, location, etc., the attachment page may be the best place to display these details.
Image-focused tutorials – For tutorials where images are the star, attachment pages can be useful for users who want to focus on a single image at a time. The previous/next navigation links allow easy browsing.
WordPress plugins – Some WordPress gallery and portfolio plugins rely on attachment pages for their lightbox features. Disabling attachment pages may break how these plugins link to images.
If you do keep attachment pages enabled, make sure to optimize them for SEO:
- Add descriptive alt text, captions, and descriptions to your images
- Include the target keyword in the image filename
- Allow comments on attachment pages to make them more valuable
- Use schema markup to specify the creator, copyright, and license info
- Add internal links from the attachment page to relevant posts/pages
By providing additional context and data, you can make attachment pages more worthwhile for both users and search engines.
Best WordPress Plugins for Image Optimization
In addition to deciding what to do with attachment pages, there are other steps you can take to optimize how you handle images in WordPress. Here are some useful plugins to check out:
Smush – This popular plugin automatically compresses and resizes images on upload to reduce file sizes without sacrificing quality. The free version lets you compress up to 50 images per month.
ShortPixel – Another handy compression plugin, ShortPixel can compress both new and existing images and PDFs. It offers lossy, glossy, and lossless compression options. 10 free credits per month.
Optimole – This plugin takes a unique approach by creating multiple versions of each image and serving the optimal size for each user‘s viewport. Includes a free CDN to speed up image loading.
EWWW Image Optimizer – Lets you choose from multiple compression tools while automatically converting images to the next-gen WebP format. The free version allows up to 10MB of image compression per month.
Using one of these plugins to compress your images can significantly reduce page load times and improve Core Web Vitals scores. Ideally, aim to keep image files under 100 kb.
FAQs About WordPress Attachment Pages
Before we wrap up, let me address some common questions about managing WordPress image attachments:
Can I disable attachment pages for specific images only?
The methods covered above will disable attachment pages globally for all images. If you need more granular control, you can use a plugin like Attachment Pages Redirect to selectively redirect attachment URLs.
Will disabling attachment pages affect my image SEO?
In most cases, disabling attachment pages will actually improve your image SEO by consolidating ranking signals and link equity around your main content. Just be sure to optimize your images on the page level.
As Jon Henshaw from Coywolf advises:
"Instead of letting attachment pages compete with or take away from your content, you can optimize images for SEO within your posts and pages…Optimizing them means compressing them, adding keyword-rich alt text, choosing a descriptive filename, adding schema, and placing them near relevant text."
Can I still use the previous/next functionality without attachment pages?
Yes, if you want to let users navigate between images in a gallery without relying on attachment pages, you can use a lightbox plugin like FooBox or Simple Lightbox. These plugins overlay images on the current page.
How does WordPress compare to other platforms for attachment handling?
WordPress is somewhat unique in automatically creating an attachment page for every uploaded image. Other CMS platforms handle this differently:
- Drupal – Only generates an image entity if you explicitly enable a standalone "image" display mode
- Ghost – Doesn‘t create separate pages for images and only links to the image file itself
- Magento – Product images don‘t get their own URLs and are displayed in a gallery on the product page
- Wix – Attachment pages are not created unless you manually add an image page using the Photos app
- Squarespace – Image links default to opening the file, with the option to create attachment pages for galleries
So WordPress‘ approach of always creating an attachment page is not necessarily the norm.
Putting It All Together
To recap, WordPress automatically generates an attachment page for every image you upload to your site. For most WordPress sites, these attachment pages are unnecessary and can hurt your SEO by creating thin, low-value content and wasting crawl budget.
The good news is that disabling attachment pages is fairly simple with the right tools. You can either use the All in One SEO plugin to automatically redirect attachment URLs to the parent page, or add a code snippet to your site using the Code Snippets plugin.
In some situations, keeping attachment pages active may be beneficial. Photography sites, image-heavy tutorials, and certain gallery plugins may have good reason to utilize attachment pages. If you do keep them, make sure to optimize the pages with relevant content and structured data.
For further image optimization, consider using an image compression plugin like Smush or ShortPixel to reduce file sizes. And follow image SEO best practices like descriptive filenames, alt text, and placement near relevant content.
By being strategic about which images deserve their own attachment pages and properly optimizing them, you‘ll create a better user experience and make it easier for search engines to understand your visual content.
I hope this in-depth guide has given you a clear roadmap for handling image attachment pages on your WordPress site. For more tips on improving your WordPress SEO and performance, check out our other guides. Feel free to leave a comment if you have any other questions!
