Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Sean Templeton
Sean Templeton
12,983 Points

How to make custom post types in WordPress

I've been following along with the "How to make a WordPress Theme" project. I've learned a lot, but the one think I haven't is how to actually make the custom post types we developed for. Is there a video or track i'm missing that teaches this? I even went through the plugin project for WordPress and I haven't learned it.

4 Answers

Hi Sean,

I haven't watched the video (I just a quick flick through), but the 2 ways I know of to create a custom post type are the following:

  1. Use a plugin.. Quick, easy, and affective (but you won't learn anything).
  2. Use the register_post_type() function

The video suggests you install a plugin (which can be found under the teacher notes section of the site)

Matt Campbell
Matt Campbell
9,767 Points

It's handled with a plugin in the course which is fine if you're building a commercial theme so that if someone changes the theme they don't lose the ability to use the data but, for bespoke sites, you don't want plugins all over it.

Read the codex. All the answers are there on how to create a custom post type via functions.php which is all the plugin does. It just uses a hook instead of being in functions.php.

Casey Ydenberg
Casey Ydenberg
15,622 Points

There's a good tutorial here to get started: http://justintadlock.com/archives/2010/04/29/custom-post-types-in-wordpress

Anything else you need you can find in the codex. Agree with Matthew that for some purposes a plugin is fine - don't reinvent the wheel.