Every time you upload an image, WordPress quietly creates a whole separate page for it — a near-empty page with just the image and its caption. Most site owners never notice, but search engines do, and they’re rarely a good look. Here’s what attachment pages are, why they usually hurt, and how to switch them off cleanly.
functions.php). One myth to drop: disabling the pages does not stop WordPress storing attachment records in the database — those are separate.WordPress generates an attachment page for every image and video you add, reachable by clicking a media thumbnail in a post or gallery. The page displays the file and its metadata — and usually little else. That “little else” is the problem.
Click an image → a standalone page holding only the image + caption. Thin, near-duplicate, a dead end. Low-value URL for search engines to index.
Same click → the post that uses the image (or the file itself). No thin page to index, visitor lands on real content. Media untouched.
Table of Contents
What attachment pages are for
They aren’t useless by design — they were meant for a few things:
- Detailed image viewing — a larger view of the image with its title, caption and description.
- Gallery navigation — in some gallery setups, clicking a thumbnail opens the attachment page to step through images.
- Deliberate image SEO — a handful of sites intentionally use them to target image-specific keywords.
If you actively rely on one of those, attachment pages earn their place. Most sites don’t — they use a lightbox or link straight to the post — so the pages just accumulate.
Why they usually hurt
For the typical site, auto-generated attachment pages are a liability:
- Thin content. Each page has almost no text — just an image and a caption. Search engines treat large numbers of thin pages as a quality signal working against you.
- Duplicate content. Many attachment pages resemble each other and their parent posts, muddying which URL should rank. Consolidating duplicates is something Google explicitly asks you to manage.
- Confusing UX. A visitor clicks an image expecting the article and lands on a bare image page — a dead end that sends them back or away.
This is the same “thin, low-value URLs dilute the site” problem that structured, intentional content is meant to avoid; it’s worth reading alongside how to structure content for SEO/AEO/GEO.
An attachment page is a whole URL whose entire content is one image and a caption — exactly the thin page search engines mark you down for.
The database myth
A common misconception: “disabling attachment pages will clean up my database.” It won’t, and it’s worth being clear about why. WordPress stores an attachment record (post type attachment) for every media file — holding its title, caption, alt text and file URL — and it needs those records to display media inside your posts. Disabling attachment pages changes only how attachments are accessed (no standalone page), not whether their records exist. If your goal is a leaner database, that’s a different job entirely.
Turning off attachment pages changes how media is accessed, not what’s stored. The database records stay — that’s a separate cleanup.
How to disable them
Pick the route that matches how you work:
- An SEO plugin (easiest). In Yoast SEO or Rank Math, turn on the “redirect attachment URLs” setting. WordPress then 301-redirects any attachment URL to the parent post (or the file), so there’s no thin page to index. This is the right choice for most sites.
- A dedicated plugin. “Disable” / “attachment page redirect” plugins do only this one job if you don’t run a full SEO plugin.
- Code (for developers). Redirect on the
template_redirecthook in your theme’sfunctions.php(or a site-specific plugin). Since it’s one small, focused behavior, it’s a fair snippet-instead-of-a-plugin candidate:
// Redirect any attachment page to its parent post (or the home page if it has none).
add_action( 'template_redirect', function () {
if ( is_attachment() ) {
$parent = wp_get_post_parent_id( get_queried_object_id() );
wp_safe_redirect( $parent ? get_permalink( $parent ) : home_url(), 301 );
exit;
}
} );
Code language: PHP (php)
After enabling any method, click an image on the front end and confirm the URL 301-redirects to the post rather than opening a bare image page.
The short version
WordPress auto-creates a standalone attachment page for every media file — usually a thin, near-duplicate page that hurts SEO and confuses visitors who click an image expecting the article. Unless you deliberately use them for galleries or image SEO, redirect attachment URLs to the parent post: Yoast SEO and Rank Math do it with one toggle, and developers can 301-redirect in functions.php. Don’t expect it to shrink your database, though — WordPress still stores an attachment record per file regardless; trimming the database is a separate task.
Frequently Asked Questions
What is a WordPress attachment page?
It’s a standalone page WordPress generates automatically for each uploaded media file, showing the file plus its title, caption and description. You reach it by clicking a media thumbnail in a post or gallery.
Should I disable attachment pages?
On most sites, yes — redirect them. They’re usually thin, near-duplicate pages that dilute SEO and dead-end visitors. The exception is if you deliberately use them for gallery navigation or image-specific SEO, in which case keep them.
Does disabling attachment pages reduce my database size?
No. WordPress still stores an attachment record (with title, caption, alt text and URL) for every media file — those are needed to display media in posts. Disabling the pages changes only how attachments are accessed, not what’s stored. Database cleanup is a separate job.
How do I redirect attachment URLs?
The easiest way is an SEO plugin: Yoast SEO or Rank Math each have a setting to redirect attachment URLs to the parent post. Developers can 301-redirect attachment requests in functions.php. Either way, test by clicking an image and confirming it lands on the post.
Will disabling attachment pages break my images?
No. Your images and galleries keep working exactly as before — the media files and their records are untouched. You’re only removing the separate per-file pages (and redirecting their URLs), not the media itself.