
What is an attachment in WordPress?
We aim to equip you, the WordPress Rockstar, with all the necessary WP knowledge you need to help you manage your photo skills in this amazing open source project. One of the terms that create confusion in WordPress is “attachment” which is used when a file is uploaded to WordPress from a page or post edit screen (see the image below). The image, you see above, is an attachment of this post because it is being used as a featured image and the one below also.
The difference between an Attachment and a file upload in WordPress
If you upload a file using the Add Media button from a post or a page edit screen, the file you are uploading would be an attachment of that post or page. Instead you can also upload a file from the Media Library – then it is not associated to a post or page and therefore doesn’t exist as an attachment in your WordPress. In short, any file you upload from a page or post using the Add Media button, the PixelRockstar Add Stockphoto button (if you already use our plugin) or as featured image, becomes automatically an attachment of your post or page.
Using the Media Library to attach an image to a post
The Media Library can be used to retrieve & add a file (image, audio,video, PDF) to a post or page once it has been uploaded there. It is all linked to the single file in the Library.
At the same time, any file that is attached to a post or page can also be removed when the post or page is deleted from WordPress. And the unique file or image can later be attached to multiple different posts or pages.
Knowing what an attachment is can be helpful for theme developers, to define specific functions or conditions for those images appearing as attachments in a WordPress page or post.
SEO trouble with attachments and Google
For each attachment you use on a page or post, WordPress creates automatically an attachment page. For some people that have very visual sites this can be great, but if your images are mainly to illustrate or support your content maybe you don’t need attachment pages. In some cases, this happened to me, an attachment page can rank higher than the original content with the “real” content article ranking next in Google. If your image is only supporting the content of your article this doesn’t make sense and you should disable or redirect the attachment pages to the original content or establish a canonical. If you use WordPress SEO by Yoast you can deal with this directly in the plugin.
Now you have learned the basics of what an attachment is in WordPress. Go ahead Rockstar and add an image to your post or page to check out how an attachment in your WordPress is created. Using the PixelRockstar plugin you can search (give it a try here) in a database of around 4 million images and add images to your posts and pages in seconds, saving your time for creating awesome content for your audience.