Tailoring search output for custom post type items
When we first declared our custom post type, we specified that its items should be excluded from search results to keep things simple. However, users are most likely to want custom items created from our plugins to appear in their site search results.
You should have already followed the Displaying single custom post type items using a custom layout 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-bookreviews/ch4-book-reviews-v3.php) from the book's GitHub page and rename the file
How to do it…
Follow these steps to learn how to include our custom post types in search results and how to customize the way they appear:
- Navigate to the
ch4-book-reviewsfolder of the WordPress
pluginsdirectory of your development installation.
- Open the