How to Add Custom Post Types (CPT)
WordPress Tutorials & How-To (Advanced)
How to Add Custom Post Types (CPT) in WordPress
Custom Post Types allow you to create new content types in WordPress beyond standard posts and pages. Whether you want to add “Projects,” “Portfolio,” “Testimonials,” or “Services,” CPTs give you full control over structure and layout. This advanced guide covers plugin-based and code-based methods, including Elementor & ACF integration.
1
What Are Custom Post Types?
Create new types of content beyond posts & pages.
A Custom Post Type (CPT) is a new content type used to store specific types of information in a structured way.
Examples of Common CPTs:
- Portfolio
- Services
- Projects
- Team Members
- Testimonials
- Recipes
- Events
- Listings
CPTs make your backend organized and your frontend layouts flexible.
2
Two Ways to Add Custom Post Types
Plugins or manual code — choose your approach.
✔ Method 1: Use a Plugin (Beginners)
Perfect if you don’t want to edit code.
✔ Method 2: Add Code Manually (Developers)
More control and performance friendly.
Both methods are explained below.
3
Method 1 — Add CPT Using a Plugin (Easiest)
Using “Custom Post Type UI” (CPT UI).
Step 1 — Install CPT UI Plugin
- Go to Plugins → Add New
- Search for Custom Post Type UI
- Install & activate
Step 2 — Create Your CPT
- Go to CPT UI → Add/Edit Post Types
- Enter:
- Slug (example: services)
- Plural Name: Services
- Singular Name: Service
- Scroll to settings
- Enable:
- Editor
- Featured Image
- Custom Fields
- Categories/Tags (optional)
- Click Add Post Type
Your new post type now appears in the WordPress dashboard.
4
Method 2 — Add CPT Using Code (Developer Method)
Add a code snippet to functions.php or a custom plugin.
Add this code to your theme’s functions.php or a custom plugin:
function sc_register_service_cpt() {
$labels = array(
'name' => 'Services',
'singular_name' => 'Service',
'add_new' => 'Add New Service',
'add_new_item' => 'Add New Service',
'edit_item' => 'Edit Service',
'new_item' => 'New Service',
'view_item' => 'View Service',
'search_items' => 'Search Services'
);
$args = array(
'labels' => $labels,
'public' => true,
'menu_icon' => 'dashicons-hammer',
'supports' => array('title', 'editor', 'thumbnail', 'excerpt'),
'has_archive' => true,
'rewrite' => array('slug' => 'services')
);
register_post_type('services', $args);
}
add_action('init', 'sc_register_service_cpt');
This creates a “Services” CPT with title, content editor, featured image, and archive page.
5
Adding Custom Taxonomies (Optional)
Categories for your CPT.
You can add custom categories like “Service Types” or “Project Categories.”
Example code:
function sc_register_service_taxonomy() {
register_taxonomy(
'service_category',
'services',
array(
'label' => 'Service Categories',
'hierarchical' => true,
'rewrite' => array('slug' => 'service-category'),
)
);
}
add_action('init', 'sc_register_service_taxonomy');
Now your Services can be categorized professionally.
6
Display CPT on the Frontend (With Elementor)
Build custom templates using Elementor Theme Builder.
Step 1 — Create a Single Post Template
- Go to Templates → Theme Builder
- Select Single Post
- Choose Services as display condition
Step 2 — Create a Dynamic Loop Archive Page
- Go to Theme Builder → Archive
- Design grid layout
- Use:
- Featured Image
- Post Title
- Post Excerpt
- Read More Button
- Set display condition → Services Archive
Now your CPT has fully custom, dynamic design layouts.
7
Use ACF (Advanced Custom Fields) for Extra Content
Add custom fields to your CPT.
Examples of custom fields:
- Service Price
- Project URL
- Client Name
- Ratings
- Gallery Images
Steps:
- Install ACF
- Create a Field Group
- Assign to Services post type
- Add fields
- Display in Elementor using Dynamic Tags
This makes CPTs extremely powerful and dynamic.
8
Common CPT Issues & Fixes
Troubleshooting tips for developers.
1. CPT 404 Error?
Go to Settings → Permalinks → Save (no changes needed).
2. CPT Not Showing in Elementor?
Go to Elementor → Settings → Post Types and enable your CPT.
3. Archive Page Not Loading?
Ensure ‘has_archive’ => true is set.
4. Custom Fields Not Showing?
Enable Show In REST in CPT UI.
Want a Website With Custom Post Types Pre-Configured?
All SiteCrafted premium websites come with advanced CPTs like Services, Portfolio, Projects, Team, and Testimonials, fully compatible with Elementor & ACF.









