Displaying posts with attachments

This scenario explains a different use of a shortcode from both a developer's perspective as well as a content creator's perspective. Here, we need to display the list of posts with at least one attachment. Unlike the previous scenario, we are not retrieving and modifying the content. Instead, we are generating dynamic content based on the shortcode attributes. Let’s take a look at the shortcode needed for this scenario:

[wpquick_attachment_posts/]

As you can see, there is no closing tag, and the closing part is done within the opening tag. These types of shortcodes are called as self-enclosing shortcodes. We don’t use any content in such shortcodes. In this case, we are displaying all the posts with attachments, ...

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.