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 trialjasonherndon
5,872 PointsPlugins for Post Types versus Coding Your Own
I'm wondering about the benefits of using plugins developed by other people versus registering your own in the theme? It would seem riskier to me to use the code of others for a lot of reasons (security, dependencies, future features and updates). I realize the two plugins you recommend are very well done and supported but wouldn't it make more sense to simply register your own? Especially if you are building more than one theme, or a parent/child theme, you can reuse your own code so you'll save time not having to download and set up these plugins with each theme. And if you intend to sell your theme, I think this would be a must. Is there a benefit to using these plugins that I'm missing?
3 Answers
Liz Karaffa
17,576 PointsCoding your own plugins by hand definitely makes sense in many scenarios, especially if you're building themes to sell or if you're building a theme for yourself that you'll maintain.
If, on the other hand, you're developing a site for a client where they may decide to change themes at will, hand-coding the custom post types would be a detriment because as soon as they change themes, they can no longer access their custom content.
My rule of thumb is that if I'll have complete control over the site for its duration and I won't be constantly changing themes, handcoded custom post types are great. But if the use of the site will be out of my control after deployment I'll use the plugins.
Damian Saunders
23,000 PointsWell, here's the thing, this is a course about developing your own Wordpress Theme. I come to this course exasperated by the use of other people's themes and plugins, and the constant reverse engineering required, hoping to make a qualified decision on whether to hard code custom post types, or use a plug in. In the context of a 'course' I feel that opting to use a plugin defeats the purpose - anyone can use a plugin. I want to know how to hard code my own custom post types.
saulo venancio
1,716 Pointsi agree with you. they should teach hwo to create custom post types, and not to use a plugin for that. horrible.
Tommaso Bufano
13,821 PointsTotally agree! I thought I'd feel empowered to create gorgeous themes for myself and to sell, and then find out 70% of the way through that they slipped this little "cheat" in there to just be quick and dirty. And they glanced right over it without explaining use cases for it and against it.
Andrew Shook
31,709 PointsJason, I prefer to code my own, because of the reasons you mentioned above and because I have a keyboard shortcut at will generate the function for me. Then all I have to do is change the settings to what I want. After you do it by code a few times, I think it's actually faster to hard code it then it is to download the plugin and add all the settings.
Nijad Kifayeh
6,092 PointsHow do you address Liz's concern about clients changing their themes and losing the custom hard-coded functionality?
Andrew Shook
31,709 PointsPut the code for the custom post types in a plugin instead of in the theme's functions.php
Tommaso Bufano
13,821 PointsIs there somewhere you can direct us to on how to create these custom plugins? I'm frustrated that they rushed through that part in this tutorial as if it's not something we should concern ourselves with when it actually is a rather important factor in developing our own themes.
jasonherndon
5,872 Pointsjasonherndon
5,872 PointsAwesome - thanks. That makes a lot of sense in terms of client work. Perhaps that's why Zac Gordon recommended this in the video. Though, the difference between the two is probably enough that I'd mention the pros and cons there.
Andrew Shook
31,709 PointsAndrew Shook
31,709 PointsAnother option to decouple the custom post typed from the theme is to code them in a plugin instead of the theme's functions.php. I usually name space the plugin after the site to prevent collisions.