Web Development 3 min read

Custom Post Types and Taxonomies in WordPress

Custom post types turn WordPress into a real application framework — portfolios, products, glossaries, events, job listings. Learn when to use them, how to register them and how to keep them SEO-friendly.

On this page

Key takeaways

  • Custom post types (CPTs) store content that isn’t a blog post or page — services, case studies, team members, products, glossary terms.
  • Custom taxonomies group them, like categories do for posts.
  • Register them in a plugin or theme with register_post_type() and register_taxonomy(), then build templates for them.

The SEO Library on this site is a custom post type called “library” with its own taxonomy for topics, its own URL structure (/seo-library/term/), templates and schema. CPTs are how WordPress becomes a real content management system rather than just a blog engine.

When to use a custom post type#

Use a CPT when… Use posts/pages when…
Content has its own structure and fields (price, duration, location) It’s a normal article
It needs its own archive and URL base It fits in the blog
Editors should manage it in a separate admin menu There are only a handful of items
Examples: services, projects, testimonials, jobs, events, glossary Examples: news, how-to articles, About page

Registering a CPT#

add_action( 'init', function () {
  register_post_type( 'case_study', array(
    'labels'       => array( 'name' => 'Case Studies', 'singular_name' => 'Case Study' ),
    'public'       => true,
    'has_archive'  => true,
    'rewrite'      => array( 'slug' => 'case-studies', 'with_front' => false ),
    'menu_icon'    => 'dashicons-portfolio',
    'supports'     => array( 'title', 'editor', 'excerpt', 'thumbnail', 'revisions' ),
    'show_in_rest' => true, // required for the block editor
  ) );

  register_taxonomy( 'industry', 'case_study', array(
    'labels'       => array( 'name' => 'Industries', 'singular_name' => 'Industry' ),
    'hierarchical' => true,
    'rewrite'      => array( 'slug' => 'case-studies/industry' ),
    'show_in_rest' => true,
  ) );
} );

After registering, visit Settings → Permalinks and click Save to flush rewrite rules.

Plugin or theme? Content types usually belong in a plugin (or must-use plugin) so the content doesn’t disappear if you switch themes. Tools like Advanced Custom Fields (ACF), Pods or Meta Box can register CPTs and custom fields without code.

Need a hand with this?

Get a quick, honest review of your website’s SEO.

Chat on WhatsApp

Templates#

  • single-case_study.php — individual item.
  • archive-case_study.php — the listing.
  • taxonomy-industry.php — items in one industry.
  • Block themes: create “Single item: Case Study” templates in the Site Editor.

Custom fields#

Structured data like client name, results, duration or price is stored as post meta. ACF, Meta Box or native register_post_meta() with block editor panels provide editing interfaces. Keep fields consistent so you can output them in templates and structured data.

SEO for custom post types#

  • Choose a clean, meaningful rewrite slug — see URL structure.
  • Make sure CPTs appear in the XML sitemap (public CPTs are included in WordPress core sitemaps automatically).
  • Add appropriate schema (e.g. Service, Event, JobPosting, DefinedTerm) — see schema in WordPress.
  • Give archives an introduction and a good title, not just a list.
  • Link CPT items from relevant posts and pages; include them in site search.
  • Set publicly_queryable to false for CPTs that shouldn’t have their own pages (e.g. testimonials shown only in sliders).

Custom post types FAQ#

Will I lose CPT content if I change themes?#

The content stays in the database, but if the CPT was registered in the theme it won’t be visible until it’s registered again. That’s why plugins are preferred.

Why do my CPT pages show 404 errors?#

Rewrite rules weren’t flushed. Save Settings → Permalinks once.

Can I use the block editor with CPTs?#

Yes, if show_in_rest is true and the CPT supports the editor.

Found this useful? Share it

Join the discussion

Your email address will not be published. Required fields are marked *

Security code image. If you cannot read it, press refresh or contact me on WhatsApp.