Beyond Posts and Pages
Out of the box, WordPress gives you two content types: Posts and Pages. Posts are for time-stamped content (blogs, news); Pages are for static content (About, Contact). But what if you're building a portfolio, a real estate listing site, or a product catalog? That's where Custom Post Types (CPTs) come in.
What Is a Custom Post Type?
A Custom Post Type is simply a new category of content you define in WordPress. It behaves like Posts or Pages but has its own name, admin menu entry, URL structure, and — optionally — its own custom fields. For example:
- A portfolio site might have a
portfolioCPT - A restaurant site might have a
menu-itemCPT - A real estate site might have a
propertyCPT
Each CPT keeps content organized, separate from your blog posts, and manageable through its own section in the WordPress admin.
How to Register a Custom Post Type
You can register a CPT by adding code to your theme's functions.php file or, better practice, inside a custom plugin. Here's a clean example for a "Portfolio" post type:
function register_portfolio_post_type() {
$args = array(
'label' => 'Portfolio',
'public' => true,
'has_archive' => true,
'menu_icon' => 'dashicons-portfolio',
'supports' => array( 'title', 'editor', 'thumbnail' ),
'rewrite' => array( 'slug' => 'portfolio' ),
);
register_post_type( 'portfolio', $args );
}
add_action( 'init', 'register_portfolio_post_type' );
Key Arguments Explained
- public: Makes the CPT visible in the admin and on the front end
- has_archive: Creates an archive page (e.g.,
/portfolio/) listing all entries - menu_icon: Sets the icon in the WordPress admin sidebar (uses Dashicons)
- supports: Defines which built-in features (title, editor, thumbnail, etc.) are available
- rewrite: Controls the URL slug for individual entries
Adding Custom Fields with ACF
CPTs become even more powerful when combined with custom fields. The Advanced Custom Fields (ACF) plugin — available in a free version — lets you add structured data fields to any CPT without writing complex code. For a "Property" CPT, you might add fields for:
- Price
- Bedrooms / Bathrooms
- Square footage
- Address and map coordinates
Using a Plugin Instead
If you prefer a no-code approach, the Custom Post Type UI (CPT UI) plugin provides a graphical interface for registering and managing CPTs directly in the WordPress admin. It's a solid option for site builders who aren't comfortable editing PHP.
When Should You Use Custom Post Types?
- You have a distinct content type that doesn't fit naturally as a blog post or page
- You need to display or filter that content type separately from your blog
- The content has unique fields that standard posts don't have
- You want clean, semantic URL structures for different content areas
Don't Forget to Flush Permalinks
After registering a new CPT, always go to Settings → Permalinks in your WordPress admin and click "Save Changes" — even without changing anything. This flushes the rewrite rules and ensures your new CPT URLs work correctly.
Summary
Custom Post Types are one of WordPress's most powerful features for building structured, content-rich websites beyond a simple blog. Once you understand how to register and use them, WordPress transforms from a blogging platform into a fully capable content management framework.