Better Custom Post Types
All the functionality you need to build a custom post type, wrapped in one big, sexy, extendable class.
Install
No release zip yet. The repository archive installs, but the folder name will carry the branch suffix and updates will not flow:
wp plugin install https://github.com/asmbs/better-cpts/archive/refs/heads/development.zipReadme
Better Custom Post Types
...and taxonomies too!
It's a plugin for your plugins.
It's all the functionality you need to build robust custom post types and taxonomies, and nothing you don't.
How to use it
- Install this plugin like ya do, either as a normal plugin or as an MU (must-use) plugin. We'd recommend the latter so it's guaranteed to be active — some pretty ugly things can happen if your plugin depends on it and it gets deactivated.
- Develop your plugin(s) separately — not on top of ours.
- Celebrate.
That's it?
Yep, Oh, but we definitely do recommend using Advanced Custom Fields — especially the pro version — for all your post metadata needs. You're not even gonna believe how sweet it is. (No, we're not affiliated, we just know a bad-ass WordPress plugin when we see it.)
The classes
CPT
Default usage:
$thing = new CPT(
'thing',
__( 'Thing' ),
__( 'Things' )
);
// From inside an init hook
$thing->register();
Use it as-is for a plain-jane custom post type, or extend it and do great and powerful things. Just override set_hooks(), register some hooks in there, implement them, and boom. Maximum custom awesomeness, minimum effort.
Taxonomy
Default usage:
$food_group = new Taxonomy(
'food-group',
__( 'Food Group' ),
__( 'Food Groups' ),
[ 'thing' ]
);
// From inside an init hook
$food_group->register();
When you're looking at a taxonomy in wp-admin, the count WordPress offers by default doesn't care about what post type you're under, so you get a total of all the posts of all post types with the given term, which is really annoying. The vanilla Taxonomy class replaces that behavior with a post count that's actually correct.