Custom Post Type Boilerplate

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.

Team post type with metaboxes.
Team post type with metaboxes.

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.

About Devin

I am a developer based in Austin, Texas. I run a little theme shop called DevPress and help manage a WooCommerce shop with Universal Yums. Find me on twitter @devinsays.

7 Responses

  1. Miguel

    Hi Devin, thank you very much for sharing!
    I have installed the plugin, and everything works fine except “menu_position” option, which seems not to work, and always appears in the admin sidebar under “settings”.
    I’m using WP 3.9.2 and the Genesis framework, if that is an important fact.
    Do you have any idea what this may be due?

  2. Thank you for the code. Easy to follow. I’m working on a project that requiered cusom post and taxonomies. In the past we would use a plugin to handle that, however we moving to a more custom design. So integrating this into our theme or plugin will be extremly beneficial.

  3. Max

    How i could for an example I make below facebook url another custom field which would be an image uploader, so i could add there some specific image (not featured image and not post thumb), like a small logo?

    I am trying to do this for a few days, and i manage to add upload button there but it doesnt pop up.

    Any suggestions?

Leave a Reply to Miguel Cancel reply