Table of Contents
Custom Post Types (CPTs) let you create content types beyond posts and pages — portfolios, testimonials, products, events, or anything structured. WordPress itself uses CPTs (attachments, menus). You can too, via code or plugin.
What Is a Custom Post Type?
A CPT is a content type with its own admin menu, URL structure, and templates. “Books”, “Movies”, or “Team Members” are CPTs. Each can have custom fields, taxonomies, and archive pages. CPTs make WordPress a true CMS, not just a blog.
Method 1: Register via functions.php
Add to your child theme’s functions.php:
function register_portfolio() {
register_post_type('portfolio', array(
'labels'=>array('name'=>'Portfolio'),
'public'=>true,
'has_archive'=>true,
'supports'=>array('title','editor','thumbnail'),
'rewrite'=>array('slug'=>'portfolio')
));
}
add_action('init','register_portfolio');
Visit Portfolio → Add New in wp-admin. The archive appears at /portfolio/.
Method 2: CPT UI Plugin
Custom Post Type UI (free) provides a GUI to register CPTs and taxonomies without code. Best for non-developers who want CPTs without touching functions.php.
Adding Taxonomies
CPTs often need custom categories. Register a taxonomy:
register_taxonomy('project-type', 'portfolio', array('label'=>'Project Type','public'=>true));
This adds a “Project Type” metabox to your Portfolio posts for grouping.
Displaying CPTs
Create archive-portfolio.php and single-portfolio.php in your theme to control layout. Or use a block pattern / query loop in Gutenberg. Without templates, WordPress falls back to default post templates.
Frequently Asked Questions
Will switching themes break my CPT? If registered in functions.php (child theme), no. If in the parent theme, yes — use a child theme or a functionality plugin (Code Snippets) to persist CPTs across theme changes.
Can CPTs be SEO’d? Yes — they’re regular content. Rank Math and Yoast support CPTs; set titles, meta, and schema per type. Submit their sitemaps to GSC.
Should I use a plugin or code? Code (functions.php or Code Snippets) is cleaner and portable. CPT UI is easier for non-coders. Both produce identical CPTs.
Conclusion
Custom Post Types transform WordPress into a structured CMS. Register them in your child theme’s functions.php (or via CPT UI), add taxonomies, and create templates. Portfolios, testimonials, and products become first-class content. Your site organizes exactly how your business works.



