I was doing a WordPress project this week that required four custom post types along with associated taxonomies and metaboxes. It’s been a while since I’ve done client work, and realized I didn’t have good boilerplate code to build these custom post type plugins from.
In the past, I’ve altered the “Portfolio Post Type” plugin which I’ve written but this has become more specialized for portfolios as Gary Jones and I have worked on it and isn’t as great a starting place as it used to be.
I think it’s really important to have quality code lying around for items like this. Building a custom post type (and especially metaboxes) from scratch each time can be a huge time waste. So, I’m throwing the final product up on GitHub in case others want to fork it and use it as their boilerplate as well.
It’s a “Team” post type and essentially does five things:
- Registers a post type
- Registers a custom taxonomy
- Registers a few metaboxes (Title, Twitter, Facebook, LinkedIn)
- Adds the featured image to the admin column display
- Adds the post count to the admin dashboard
Even though it’s designed for a “team”, it just takes a couple minutes to go through and alter everything to make it work for a different type of data.
If you see anything huge I missed, feel free to send a pull request. I hope it saves you some time on your next project! View the code.