Welcome to the Treehouse Community
Looking to learn something new?
Sean Templeton12,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.
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:
- Use a plugin.. Quick, easy, and affective (but you won't learn anything).
- 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 Campbell9,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 Ydenberg15,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.
Zac GordonTreehouse Guest Teacher
Check out this video: http://teamtreehouse.com/library/how-to-build-a-wordpress-theme/content-strategy-with-wordpress/custom-post-types-and-fields-2 and then the next one. Should go over what you're looking for.