The Kitchen Sink
Brad Williams, Justin Tadlock, John James Jacoby · 2020
This chapter helps the reader to learn some use cases for displaying posts in the context of the plugin, get an overview of how to query posts from the database, and learn about the all-important loop for outputting posts. It also helps the reader to built a “book” post type for plugin user to store their book collection. To display posts, people must first query them from the database. WordPress has several functions for querying posts. However, they all eventually run through the WP_Query class. The loop in WordPress is just a fancy of way of saying to check whether any posts are available from a post query and to loop through them. Technically, the actual loop is a PHP while loop that loops through the found posts. The chapter explains how to create simple shortcodes to allow plugin users to enhance their posts.