Attachment is a built-in WordPress post type that represents a media file — an image, PDF, video, audio file, or document — uploaded through the WordPress media system. Every file you add to the Media Library creates an attachment record in the WordPress database, storing metadata about the file: its title, caption, description, alt text, file path, and MIME type.
Unlike posts or pages, attachments aren’t content you write — they’re content you upload. But WordPress treats them similarly under the hood: each attachment gets its own post ID, its own URL structure, and by default, its own publicly accessible attachment page. Understanding how attachments work helps you manage your media more effectively and avoid some common SEO pitfalls that catch many site owners off guard.
How Attachments Work in WordPress
When you upload a file to WordPress, the system:
- Saves the file to the
wp-content/uploads/directory, organized by year and month - Creates a database entry in the
wp_poststable withpost_type = 'attachment' - Stores file metadata (dimensions, file size, EXIF data for images) in the
wp_postmetatable - Generates multiple image sizes based on your thumbnail settings (for images)
- Creates an attachment page — a publicly accessible URL displaying the file, typically at a URL like
/photo-name/or/?attachment_id=123
The attachment page can be rendered by your theme using an attachment.php template, or it falls back to single.php or index.php depending on what your theme includes. In most cases, these pages display the file with very little surrounding content — which is relevant for SEO decisions.
Starting in WordPress 6.4, new installations have attachment pages disabled by default, redirecting visitors to the media file itself rather than displaying a thin attachment page.
[Image: Screenshot of WordPress Media Library showing an image’s attachment details panel with Title, Caption, Alt Text, and Description fields]
Purpose & Benefits
1. Centralized Media Management
The attachment system gives you one place to manage all uploaded files — the Media Library. From there, you can edit titles, captions, alt text, and descriptions for every file without editing individual posts or pages. This metadata travels with the file wherever it’s used across your site. Our team at WordPress development services configures media settings as a standard part of every build.
2. Metadata That Supports SEO
Every attachment stores an alt text field, which renders as the alt attribute on <img> tags — a direct factor in image SEO and accessibility. Captions and descriptions add readable context around images on attachment pages, and for sites like photography portfolios, this metadata can be genuinely valuable for search indexing.
3. Programmatic Access to Media Files
Because attachments are a post type, developers can query and manipulate them using WordPress’s native functions: get_attachment_url(), wp_get_attachment_image(), and WP_Query with post_type => 'attachment'. This makes it straightforward to build galleries, custom portfolio displays, or downloadable resource libraries without a plugin.
Examples
1. Image Gallery for a Service Business
A home renovation company uploads project photos through the Media Library. Each image gets descriptive alt text and a caption. Those attachments are then inserted into a gallery block on the Projects page. The attachment metadata — title, caption, alt text — populates automatically in the rendered gallery, supporting both accessibility and image search visibility.
2. PDF Downloads on a Resource Page
A law firm uploads several PDF guides through the Media Library. Each attachment record gets a clean title (“Estate Planning Guide 2025”) and a short description. The firm links directly to the media files from their Resources page rather than to attachment pages, giving visitors a direct download with no intermediate thin page.
3. Photography Portfolio Theme
A photographer uses a theme specifically designed for attachment pages. The theme’s image.php template pulls EXIF data from each photo (camera model, shutter speed, focal length) and displays it alongside the full-size image and description. In this case, attachment pages add genuine value and are worth keeping publicly accessible.
Common Mistakes to Avoid
- Leaving attachment pages publicly indexed with no content — On most business sites, attachment pages contain only an image and a filename-derived title. Google may index hundreds of these thin pages, which can dilute your site’s overall content quality. For sites that don’t add rich metadata to attachments, redirecting or noindexing these pages is standard practice.
- Skipping alt text and other metadata fields — The Title, Caption, Alt Text, and Description fields in the media uploader are there for a reason. Leaving them empty is a missed SEO and accessibility opportunity that compounds across every image on your site.
- Uploading media with generic filenames — Files named
IMG_4873.jpgdon’t help search engines understand the image content. Rename files descriptively before uploading —kitchen-remodel-oak-park-before.jpg— since the filename becomes part of the file’s URL. - Confusing the attachment page URL with the media file URL — The attachment page (
/photo-name/) and the direct media file URL (/wp-content/uploads/year/month/photo-name.jpg) are different things. Linking visitors to the attachment page when you intend a direct download creates unnecessary friction.
Best Practices
1. Decide on Attachment Page Handling Early
For most business websites, the right call is to disable attachment pages (WordPress 6.4+ default) or redirect them to the parent post. If you’re on an older install, SEO plugins like Yoast SEO and All in One SEO both include settings to redirect attachment URLs to their parent page or to the media file itself. Making this decision at site launch avoids having to clean up indexed thin pages later.
2. Fill in Media Metadata Consistently
Build a habit of completing the Alt Text, Title, and Caption fields every time you upload media. Alt text is required for accessibility compliance and directly affects image SEO. A brief, descriptive caption appears in many theme layouts below images and adds readable context for visitors. For featured images especially, complete metadata matters.
3. Organize Your Media Library
Use the Media Library’s built-in filtering and the optional folder plugins to keep uploads organized. A site with hundreds of uploads becomes difficult to manage if images are scattered with no naming convention. Consistent naming and organized structure also makes it easier to audit media metadata quality across the site.
Frequently Asked Questions
What’s the difference between an attachment and a media file?
They’re two sides of the same thing. The media file is the actual binary file stored on the server. The attachment is the WordPress database record that tracks that file — its metadata, its relationship to posts or pages, and its URL. When people say “attachment” in a WordPress context, they usually mean this database record and the page it generates.
Should I noindex WordPress attachment pages?
For most business websites, yes — or redirect them entirely. Attachment pages on sites that don’t add rich metadata typically contain only a bare image or file with minimal surrounding content. Hundreds of these thin pages can dilute your site’s content quality in Google’s view. The exception is sites where attachment pages carry genuine value, like photography portfolios with detailed EXIF data and descriptions.
Does deleting a post also delete its attachments?
No — not by default. When you delete a post or page, WordPress moves it to the Trash but leaves any attached media files in the Media Library. You’d need to delete the media files separately. This means your Media Library can accumulate unused files over time, which is worth cleaning up periodically.
What image sizes does WordPress create for each attachment?
By default, WordPress generates thumbnail (150×150), medium (300×300 max), medium_large (768px wide), and large (1024×1024 max) sizes in addition to the original. Your theme may register additional sizes. All these resized copies are stored in the uploads directory alongside the original.
Can I change the URL structure for attachment pages?
The attachment page URL is derived from the attachment’s slug (post name), which defaults to the filename. You can edit the slug in the Media Library’s attachment details panel. The URL structure itself follows your site’s permalink settings.
Related Glossary Terms
How CyberOptik Can Help
Understanding how WordPress handles attachments under the hood helps you make better decisions about your media, SEO, and site performance. Our team manages attachment settings, media metadata, and attachment page handling for clients every day — from initial site configuration to ongoing maintenance. If your site has an accumulation of unoptimized attachment pages or media that needs organizing, we can help you address it cleanly. Get in touch to discuss your project or explore our WordPress development services.


