Attachment Post hierarchy

In WordPress, files uploaded to the media library or assigned to posts are considered attachments. The diagram shows templates going up to seven levels for attachments. However, we rarely use these templates unless the primary feature of the site is managing attachments. Therefore, the single.php template will be responsible for handling attachments in most themes. We are not going to discuss the optional templates due to their lack of use.

You can go to Media | Library and click on one of the attachments. Then, you can click the View Attachment Page link to view the attachment using the single.php file. If your site requires that you change the default template, you should add the attachment.php file to the child ...

Get WordPress Development Quick Start Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.