You should never use themes that incorporate their own Custom Post Types, because they will disappear when you change themes.
What are Custom Post Types?
By default WordPress comes with “Posts” and “Pages”. But there is a feature that allows us to create new types of content: Custom Post Types. Custom Post Types are new types of content that we can add to WordPress. For example, in my case I have: News, pages, podcasts, courses, tutorials and downloads.
Custom Post Types can be added mainly in two ways:
- Through a theme
- Through a plugin
Let’s take a look at both approaches and see why it is a very bad idea for a theme to incorporate its own Custom Post Types.
Custom Post Type in a Theme
This method should be avoided at all costs, since all those Custom Post Types that come with a theme, will disappear when we deactivate it.
For example, when we activate the never recommended Divi, we realize that in the control panel the Custom Post Type “Projects” has appeared out of nowhere. In principle this may seem like a good thing, because you think “Oh, great, so I have everything in the theme, and I don’t need to install a plugin“, but the problem is precisely there! You must use a plugin!
Why do you have to use a plugin? Imagine for a moment that you use Divi’s Custom Post Type. Everything seems to be working great, and you’re creating content day after day, year after year. Until one day, you decide to change your theme. Sooner or later it will happen, believe me. There will be a day that for whatever reason, you will want a newer theme, more different, lighter (remember that Divi is very slow), or simply for design reasons.
Do you know what will happen when you deactivate Divi and activate another theme? Well, all the content that was inside the Custom Post Type of the Theme will be deleted because it is property of the Theme. So if we delete the Theme, we delete everything. Obviously they have not been “deleted”, since they are still in the database, but recovering them now will be a problem, because it is not only a matter of recovering the Custom Post Types, but also all the Custom Fields that go with them. What do we do now?
This is what is called “Lock-in” effect. That is, you are “locked” in that theme. This is done by the theme developers so that you never leave them, and you are bound to their themes, without having the option to change. So where should these Custom Post Types be defined? Easy! In plugins. And if it is with a child theme much better, here we show you the differences between a parent theme and a child theme and the importance of doing it right.
We must use Custom Post Types in Plugins
Unlike themes, all the code that comes in a plugin is maintained even if we change the theme. If we add a new plugin on sidebar, portfolio, contacts, etc, the plugin will add a new Custom Post Type in our sidebar of the WordPress admin panel. If we now change theme, all this information is maintained, with their respective custom fields.
So, theme developers who want to create features such as Custom Post Types, what they should do is create a plugin independent of their theme, which complements it. There are several ways to do that.
That way we have a couple of very important advantages:
- The user will only install the plugin if he needs the Custom Post Types. Otherwise, why have all that code there? We gain in performance and speed!
- If the user wants to use it and one day wants to change the theme, he doesn’t lose any content, and everything continues to work correctly. We win in freedom!
In fact, even the theme developer wins, because he can be known both for his themes and his plugins. Winning strategy. But there are still many who prefer to continue with the “lock-in” techniques to force users to stay with them. That’s why in the WordPress.org theme review team we don’t accept themes in the official repository that have Custom Post Types incorporated. Because it is forbidden to put anything in a theme that will cause content loss if the theme is left. Custom Post Types with custom content types in WordPress. Some themes have it built in, but we should avoid them, because if one day we change theme, we lose everything.
If we want to incorporate a new type of content, it is advisable to do it through a plugin.