A WordPress agency adds a custom post type called event for a client. It works. Two years later, the same agency picks up a different client, also wants an event CPT — but with completely different fields. The first agency uses ACF, the second uses Meta Box. Now they have two CPTs that share a name, conflict in URL structure, and can’t both ship if the client ever consolidates. The CPT decisions you make in week one constrain you for years. Naming, slug strategy, query performance, and capability mapping all need to be right from the start.
What’s happening
A WordPress custom post type is a register_post_type() call. The function takes 30+ arguments and most of them have defaults that work for blog posts. CPTs that look like posts (events, projects, case studies) often inherit those defaults silently, then surprise the team when a feature lands wrong — archives don’t work, the REST API returns 404, taxonomies aren’t filterable.
The four common gotchas:
- Naming collision.
event,product,teamare all common CPT names that ship in popular plugins (The Events Calendar, WooCommerce, Team plugins). Use a vendor prefix. - Slug rewrites. The default URL is
/event/example-name/. If you ever want/events/example-name/(plural), you need'rewrite' => ['slug' => 'events']AND a permalink flush. - Capabilities. CPTs default to the
postcapability map, so anyone who can edit posts can edit your CPT. If editorial separation matters, register a custom capability set. - Performance. WordPress queries CPTs through the same
wp_poststable. A CPT with 500,000 entries shares that table withpost,page,attachment, and revisions — a query withoutpost_typefilter scans everything.
How to verify
Inventory CPTs registered on a site:
wp post-type list --fields=name,label,public,has_archive,rewrite --format=table
For each custom one, confirm the rewrite slug and the archive:
curl -sI "https://example.com/event/" | head -5
curl -sI "https://example.com/?post_type=event" | head -5
If /event/ returns 404 and /?post_type=event returns 200, the rewrite slug isn’t flushed — run wp rewrite flush.
For capability mapping, check what role can do what:
wp eval '
$pt = get_post_type_object("event");
print_r($pt->cap);
'
If you see edit_posts, edit_others_posts, etc., the CPT uses the default post capabilities. That’s fine for most cases but means anyone with author role can create events.
What to do
The decisions in order of how much they constrain you later.
-
Name it with a vendor prefix.
eventis taken.acme_eventoracme-eventis not. Internal name (the first argument toregister_post_type) should never be a single common word. -
Decide on plural vs singular URL early. Default is singular (
/event/), which is fine if you’re sure. For SEO and convention, plural is more common — but plural means settingrewriteANDhas_archivecorrectly:
register_post_type('acme_event', [
'labels' => [
'name' => 'Events',
'singular_name' => 'Event',
],
'public' => true,
'has_archive' => 'events', // /events/
'rewrite' => ['slug' => 'events/event'], // /events/event/example/
'menu_icon' => 'dashicons-calendar',
'supports' => ['title', 'editor', 'thumbnail', 'excerpt', 'custom-fields'],
'show_in_rest' => true, // critical for Gutenberg + REST API
'rest_base' => 'events', // /wp-json/wp/v2/events/
'taxonomies' => ['acme_event_type'],
]);
- Decide on capability separation. If editorial workflow matters (clients edit events but not posts), use custom capabilities:
'capability_type' => ['acme_event', 'acme_events'],
'map_meta_cap' => true,
Then grant edit_acme_events, publish_acme_events to the appropriate role with add_role() or via a plugin like Members.
-
show_in_restshould betrue. Without it, Gutenberg can’t edit the CPT and the REST API returns 404. This is the most common mistake — defaults tofalse. -
supportsarray dictates which meta boxes appear. Without'thumbnail'you don’t get the featured image box. Without'excerpt'you don’t get the excerpt field. Add only what the data model actually needs. -
Performance: index the meta keys you query. If you
meta_queryonevent_date, add a MySQL index:
wp db query "ALTER TABLE wp_postmeta ADD INDEX idx_event_date (meta_key(20), meta_value(20));"
Or use a custom table for high-cardinality data (event_attendees) — wp_postmeta is fine for under 100k rows per meta key, slow above.
-
Register taxonomies in the same hook. CPT registration goes in
initpriority 10; taxonomy registration also ininitpriority 10 or earlier. Out-of-order registration breakstaxonomiesargument bindings. -
Plan for unregistration. If the CPT is plugin-bound, register a deactivation hook that does NOT delete posts (data preservation) but does flush rewrites:
register_deactivation_hook(__FILE__, function() {
flush_rewrite_rules();
});
For the surrounding data modeling — when to use a CPT vs a custom table vs taxonomies — see WordPress custom taxonomies performance.
Stack Harbor’s Enterprise WordPress practice audits CPT design as part of every plugin onboarding. If a site has 12 CPTs registered by various agencies with overlapping slugs, we can do the audit and consolidation.