WordPress is more than a blogging platform—it’s a flexible content management system that can be extended far beyond posts and pages. One of the most powerful features enabling this flexibility is Custom Post Types (CPTs). These allow developers and content managers to structure content for specific use cases like portfolios, events, product directories, podcasts, or glossaries—each with their own admin areas, categorization, and front-end templates.
In this guide, we’ll explore what CPTs are, how to create them (both via plugin and code), how to register custom taxonomies that differ from default blog categories and tags, and how to build custom templates for them in your child theme properly. We’ll use a Glossary CPT as a working example.
Table of Contents
What Is a Custom Post Type?
A Custom Post Type behaves like a regular blog post but lives in its section of the WordPress admin and on the front end. It’s perfect for content that doesn’t belong in your blog stream—for example, a list of marketing terms, product specs, or real estate listings. Use cases include:
- Glossaries for technical or industry terms (this is how we built our Acronyms)
- Testimonials that don’t belong in blog posts
- Case Studies with structured metadata
- Recipes, Courses, Team Members, or FAQs
How to Create a Glossary CPT
Let’s build a Glossary CPT. This is ideal for websites that want to offer a well-organized, categorized list of terms with definitions.
Option 1: Use a Plugin
Install the Custom Post Type UI plugin.
- Go to CPT UI → Add/Edit Post Types
- Add a new post type:
- Slug:
glossary
- Plural Label:
Glossary
- Singular Label:
Term
- Slug:
- Enable features like title, editor, excerpt, and custom fields
- Save the post type
Then use the same plugin to add a custom taxonomy like Topic
for categorizing terms.
Option 2: Add It Programmatically
Insert the following code into your child theme’s functions.php
file or a custom plugin:
function register_glossary_post_type() {
$labels = array(
'name' => 'Glossary',
'singular_name' => 'Term',
'menu_name' => 'Glossary',
'name_admin_bar' => 'Glossary Term',
'add_new' => 'Add New',
'add_new_item' => 'Add New Term',
'new_item' => 'New Term',
'edit_item' => 'Edit Term',
'view_item' => 'View Term',
'all_items' => 'All Terms',
'search_items' => 'Search Terms',
'not_found' => 'No terms found',
);
$args = array(
'labels' => $labels,
'public' => true,
'menu_icon' => 'dashicons-book-alt',
'has_archive' => true,
'rewrite' => array('slug' => 'glossary'),
'supports' => array('title', 'editor', 'excerpt', 'custom-fields'),
'show_in_rest' => true,
);
register_post_type('glossary', $args);
}
add_action('init', 'register_glossary_post_type');
Add a Custom Taxonomy: Glossary Topics
Now register a custom taxonomy (e.g., glossary_topic
) to group your terms by subject matter:
function register_glossary_taxonomy() {
$labels = array(
'name' => 'Topics',
'singular_name' => 'Topic',
'search_items' => 'Search Topics',
'all_items' => 'All Topics',
'edit_item' => 'Edit Topic',
'update_item' => 'Update Topic',
'add_new_item' => 'Add New Topic',
'new_item_name' => 'New Topic Name',
'menu_name' => 'Topics',
);
$args = array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'show_in_rest' => true,
'show_admin_column' => true,
'rewrite' => array('slug' => 'glossary-topic'),
);
register_taxonomy('glossary_topic', array('glossary'), $args);
}
add_action('init', 'register_glossary_taxonomy');
Creating Custom Templates for CPTs in Your Child Theme
To make your CPT display beautifully on the frontend, you need two key templates inside your child theme:
1. archive-glossary.php
This file controls the appearance of the glossary archive page at yoursite.com/glossary
.
Place it in your child theme root:
<?php get_header(); ?>
<h1>Glossary</h1>
<div class="glossary-archive">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<article class="glossary-entry">
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<div class="excerpt"><?php the_excerpt(); ?></div>
<p><strong>Topic:</strong> <?php the_terms(get_the_ID(), 'glossary_topic'); ?></p>
</article>
<?php endwhile; else : ?>
<p>No glossary entries found.</p>
<?php endif; ?>
</div>
<?php get_footer(); ?>
2. single-glossary.php
This file controls the individual term view, such as yoursite.com/glossary/seo
.
<?php get_header(); ?>
<article class="glossary-term">
<h1><?php the_title(); ?></h1>
<div class="entry-content">
<?php the_content(); ?>
</div>
<footer>
<p><strong>Topic:</strong> <?php the_terms(get_the_ID(), 'glossary_topic'); ?></p>
</footer>
</article>
<?php get_footer(); ?>
If these template files are not present, WordPress will fall back to more generic templates like archive.php
or single.php
, which may not be styled appropriately.
Optional: Custom Rewrite Rules for Pretty URLs
If you’d like to create URL structures like /glossary-topic/seo/
, you can enable rewrite_with_front => false
when registering the taxonomy and flush permalinks by visiting Settings → Permalinks after updating your code.
Why Use CPTs Instead of Posts?
Using CPTs keeps your content well-organized and separate from your blog. For example, glossary entries don’t belong in the blog feed or in your “Latest Posts” widget. CPTs also make it easier to:
- Build custom admin interfaces
- Apply different SEO settings or schemas
- Use different templates and layouts
- Query content selectively (e.g., only glossary terms)
- Set custom user permissions or workflows
Summary
Custom Post Types and custom taxonomies unlock the full potential of WordPress as a CMS. Whether you’re building a knowledge base, a directory, or an editorial system, CPTs help you structure your data intelligently and present it beautifully. By combining CPTs with custom archive and single templates in your child theme, you create a seamless editing and reading experience tailored to your content model.