As I write this, I’m working on a project that called for a number of custom post types for creating and managing content (six to be exact). To provide some context, the project is a sports blog and the custom post types are for each sport written about (NFL, NBA, MLB, etc.) on the blog. I could have just set up regular posts with a “Sport” category, but that’s more like making the content bend to WordPress rather than making WordPress work for the user’s needs. Additionally, going the standard posts route would have been more difficult in general because each sport requires further, custom taxonomies (i.e. Team name). Therefore, custom post types for this project were a no-brainer.
Making Custom Post Types Show on Home Page
Once the custom post types were set up and content was being added, I needed a way to show recent sports posts on the front page. Since having WordPress show your latest posts on the front page only pulls from “Posts”, I needed a workaround. Here’s the snippet that I put together to pull from the required custom post types.
You will need to edit the post type array and, depending on your needs, you may also need to modify the conditional.
Leave a Reply