The term attachment is used for files uploaded to WordPress from post edit screen. When a file is uploaded using the Add Media button from post edit screen, that file automatically becomes an attachment of that particular post. Files uploaded directly to the Media Library are not particularly attached to a post or page. An attachment can be any file that can be uploaded using the media upload.
Theme developers can use attachment feature using template tags and conditional template tags to manipulate the appearance of the posts with the attachments. One common example of developers using attachments in conjunction with posts is the use of Post Image; these images can be set to a default, a category image, or a new image for each post (which could be a attachment of that post displayed in the particular way that the theme is setup to display it).
Media Library sub panel can also be used to attach media to specific posts after having been uploaded into the media library. Media that is uploaded into a specific post, or referenced into a specific post automatically becomes attached to that post. Media that is attached to posts can also become unattached when the posts are deleted from WordPress. These posts can become re-attached to a new post in the same way that they were attached to the original post. Media can also be attached to multiple posts at the same time and become unattached to any one of the posts if needed.
This post was originally published in the wpbeginner glossary.