By default, WordPress comes with five built-in post types: posts, pages, attachments, revisions, and menus. But what if you want to create a new content type like Portfolio, Testimonials, FAQs, or Properties? That’s where Custom Post Types (CPTs) come into play. (how to create a custom post type in WordPress)
In this complete beginner’s guide, you’ll learn what a custom post type is, how to create one using code and plugins, when and why to use them, and the best practices to follow. By the end, you’ll be able to organize and display your content more effectively in WordPress.
What is a Custom Post Type?
A Custom Post Type is a content type just like Posts and Pages, but with its own label, settings, and features. It allows you to create dedicated sections for content types specific to your website.
Example Use Cases:
portfolio
post type for a design portfoliotestimonial
for client reviewsevent
for listing events with date/timeproduct
for custom eCommerce setup
Custom Post Types make your site more organized and scalable.
Method 1: Creating a Custom Post Type Using Code (functions.php)
If you’re comfortable with editing theme files, you can register a CPT manually using PHP.
📌 Add This Code to Your functions.php
File:
function solvewp_register_portfolio_post_type() { $labels = array( 'name' => 'Portfolios', 'singular_name' => 'Portfolio', 'menu_name' => 'Portfolios', 'add_new_item' => 'Add New Portfolio', 'edit_item' => 'Edit Portfolio', 'new_item' => 'New Portfolio', 'view_item' => 'View Portfolio', 'all_items' => 'All Portfolios', ); $args = array( 'labels' => $labels, 'public' => true, 'has_archive' => true, 'rewrite' => array('slug' => 'portfolio'), 'show_in_rest' => true, // Enable Gutenberg 'supports' => array('title', 'editor', 'thumbnail', 'excerpt'), 'menu_icon' => 'dashicons-portfolio' ); register_post_type('portfolio', $args); } add_action('init', 'solvewp_register_portfolio_post_type');
🔍 Result:
- New menu item “Portfolios” appears in admin sidebar
- Can create, edit, and manage Portfolio items
- Archive accessible at
/portfolio
(unless permalink conflicts exist)
💡 Tip: Always use a child theme when editing
functions.php
.
Method 2: Using a Plugin (No Code)
For beginners who prefer not to touch code, you can use plugins like:
🔧 Custom Post Type UI (CPT UI)
Steps:
- Install and activate the plugin
- Go to CPT UI > Add/Edit Post Types
- Enter slug (e.g.,
portfolio
) - Fill in labels and options
- Click Add Post Type
Benefits:
- User-friendly interface
- Supports custom taxonomies too
- Safe for beginners
⚠️ Plugin just registers CPTs. Use a display plugin (like Elementor, Pods, or custom queries) to show them on the front-end.
Displaying Custom Post Types on Your Site
By default, CPTs won’t show on your homepage or blog archive. You have options:
1. Create a Custom Template File
Use archive-portfolio.php
or single-portfolio.php
in your theme.
2. Use WP_Query Loop
$args = array( 'post_type' => 'portfolio', 'posts_per_page' => 10 ); $query = new WP_Query($args);
3. Use a Page Builder Plugin
Elementor Pro and others can fetch custom post types using dynamic listings.
When to Use a Custom Post Type vs a Category?
Use a CPT when:
- The content is fundamentally different in structure and purpose
- You want different meta boxes, templates, or admin menu
Use a category when:
- You’re grouping similar blog content
- The structure/content type remains the same
Best Practices for Custom Post Types
- Use singular slugs (e.g.,
testimonial
, nottestimonials
) - Create separate templates for display
- Always use
show_in_rest => true
for Gutenberg support - Register custom taxonomies if needed (e.g., event categories)
- Backup before making file changes
External Resources
- Registering a Post Type – WordPress Developer Docs
- Custom Post Type UI Plugin
- Advanced Custom Fields (ACF)
Internal Related Articles (on SolveWP.in)
- How to Use Shortcodes in WordPress
- How to Install a WordPress Plugin
- How to Create a Child Theme in WordPress
Final Thoughts
Creating custom post types allows you to go beyond the default WordPress functionality and design your content structure to suit your project. Whether you’re managing portfolios, FAQs, properties, or events — CPTs give you complete control.
Choose between code or plugins based on your skill level. Either way, make sure your site remains clean, organized, and scalable.
💬 Still have questions? Drop a comment or browse our tutorials on SolveWP.in.