Displaying single custom post type items using a custom layout
When displaying an entry created in our new custom post type, the default layout offered by our current site theme may not always be able to pleasantly display the information it contains. In most cases, you will be able to see the main post content, but not any of the custom fields data that is associated with the post.
You should have already followed the Adding a new section to the custom post type editor recipe to have a starting point for this recipe and the resulting plugin should still be active on your development site. Alternatively, you can get the resulting code (
ch4/ch4-book-reviews/ch4-book-reviews-v2.php) from the book's GitHub page and rename the file
How to do it...
Follow these steps to create a custom layout to display all the elements that we stored in the book review created in the previous recipe:
- Navigate to the