Comparing WordPress Post Types and Statamic Collections
For any modern complex website, custom data types beyond “posts” and “pages” are nearly always a given. It’s not unlikely for even a basic marketing website that you might require something along the lines of “people” to list your staff, or “locations” to indicate each place your business operates.
I published a video on YouTube going over the different approaches in both WordPress and Statamic. Watch it here:
WordPress Custom Post Types
In WordPress, in order to achieve this we need to either generate some code to create a new “post type” (everything is a post in WordPress), or lean on a plugin such as Advanced Custom Fields Pro, which provides a UI to do this in its most recent major releases.
If you want to go the code route, you might look to a site like GenerateWP to generate all of the code for your new post type. It’s one of those things that nobody is likely to have internalized such that we could remember everything and write it from memory by hand. With this, you can configure all the things you might need, though you’ll likely still need to make changes should you need a more complex routing pattern, for instance.
In any case, you introduce some overhead with your custom code that needs to be shoved into your functions.php
in your theme, or else placed in a plugin. Either way will get you the result you need. Then, you’re dependent on the theme’s single.php
and archive.php
to render the index and the single post views, unless you decide to make your own following the WP template hierarchy pattern.
Once this is in place, we get access to the block editor, just like pages and posts, unless we change the registration function to default to the “classic” editor.
Statamic Collections
Let’s compare this now with Statamic, where this concept is baked into the core of the platform. With a single click, we can create a new “collection,” and with another, can scaffold the index and show templates for the relevant views.
Out of the box, the Blueprint we get (which is automatically created for us) the title, content, and template fields, and configuring the collection gives us the power to structure it with dates, select the sort orders, link taxonomies, and select the routing pattern we want to use, all within the UI. This is quite a bit more cumbersome, but still achievable with a mix of the ACF Pro plugin, and more hooks and filters to create or associate taxonomies or modify the sorting.
Did I mention this is a core feature in Statamic? I don’t need to install a plugin or generate custom code to create my collection; the only code I need to write is to output the content from within the view template files, which would be expected in WordPress also. The collection
tag lets me iterate over the entries in my index view, and I get the fields in the show view automatically as well.
Ultimately, this is a huge development productivity win, and all of these things in the Control Panel make understanding the content models so much easier for editors. Sounds like a win win to me.