What is Attachment Page in WordPress?

Attachment is a post type in WordPress that is used for any files uploaded and assigned to a post or page. For example, you can upload an image using an image block in Gutenberg block editor. WordPress will attach the uploaded image to that particular post and assign a unique URL to access the image.

Attachment URL Example:

Let us take an example that we upload an image named “WordPress-User-Section” to a post “how-to-delete-user-in-wordpress/”. In this case, below are the URLs you will get:

ExampleURL Type
https://wp-tips.com/how-to-delete-user-in-wordpress/Post URL
https://wp-tips.com/wp-content/uploads/2020/11/WordPress-User-Section.pngImage Address
https://wp-tips.com/how-to-delete-user-in-wordpress/WordPress-User-Section/Attachment Page URL

Attached and Unattached

You can view an image is attached or unattached from “Media > Library” section of your admin panel. Make the view to list view and check under “Uploaded to” column. If the image is already attached, you will see the post URL and “Detach” option.

Attached Images
Attached Images

If you have directly uploaded images through “Media > Library” section, then they will in unattached status. For example, your logo and favicon are unattached images since they are uploaded in post editor.

Unattached Images
Unattached Images

Where Can I See Attachment?

When you upload an image or media file through post editor, you will only see the “File URL”. This file URL is the image address and not the attachment URL. In order to view the attachment URL, go to “Media > Library” section and change the view to grid view.

Media in Grid View
Media in Grid View

Click on any image and then hover over the link at bottom that says “View attachment page”. This is the attachment page URL of the image you have uploaded.

View Attachment URL in WordPress
View Attachment URL in WordPress

Few Important Points to Note:

1. Redirecting attachment
RELATED:  How to Delete User in WordPress?

Since attachment page only contains the uploaded image, users landing on that page will get disappointed expecting some content. In order to avoid this, you can redirect all attachment page URLs to the uploaded image URL using Yoast SEO plugin. You can do this under “SEO > Search Appearance > Media” section of Yoast SEO plugin and enabling “Redirect attachment URLs to the attachment itself?”Redirect Media Attachment to Post

2. Attachment Post Type

You can view all attachment details in “wp-posts” table of your WordPress site’s database.

3. Attachment Template

WordPress uses “attachment.php” for rendering attachment pages and offers “attachment_template” to use in the template hierarchy.

Article last updated on November 6, 2020

Leave a Comment