Experience the powerful AI writing right inside WordPress
Show stunning before-and-after transformations with image sliders.
Improve user engagement by showing estimated reading time.
Written by Tasfia Chowdhury Supty
Showcase Designs Using Before After Slider.
WordPress comes with default post types like Posts and Pages, but sometimes, you need more structured content. That’s where custom post types (CPTs) come in!
Creating custom post types in WordPress allows you to organize different types of content, such as portfolios, testimonials, events, or products. This guide will walk you through:
✅ What a custom post type is✅ Types of custom post types in WordPress✅ How to create custom post types (with & without plugins)✅ Best practices for using CPTs✅ Frequently asked questions (FAQs)
Let’s get started! 🚀
A custom post type (CPT) is a content type in WordPress that extends beyond standard posts and pages. It allows you to create and manage different content structures tailored to your website’s needs.
For example, a portfolio website may need a Portfolio post type, while a real estate website may need a Property Listings post type.
Custom post types help separate different types of content, making management easier.
Users can navigate your site more efficiently with structured content.
Structured content can be optimized for better rankings in search engines.
CPTs work seamlessly with custom taxonomies and fields for deeper customization.
You can manually register a custom post type in WordPress by adding code to the functions.php file of your theme or a custom plugin.
functions.php
function create_custom_post_type() { $args = array( 'labels' => array( 'name' => 'Portfolios', 'singular_name' => 'Portfolio', ), 'public' => true, 'has_archive' => true, 'supports' => array('title', 'editor', 'thumbnail', 'excerpt', 'comments'), 'menu_icon' => 'dashicons-portfolio', ); register_post_type('portfolio', $args); } add_action('init', 'create_custom_post_type');
Use the following loop in a custom page template or widget:
<?php $portfolio_query = new WP_Query(array('post_type' => 'portfolio', 'posts_per_page' => 6)); if ($portfolio_query->have_posts()) : while ($portfolio_query->have_posts()) : $portfolio_query->the_post(); ?> <h2><?php the_title(); ?></h2> <p><?php the_excerpt(); ?></p> <?php endwhile; wp_reset_postdata(); endif; ?>
If you don’t want to edit code, you can use a plugin like Custom Post Type UI (CPT UI).
portfolio
Portfolios
Portfolio
Your custom post type is now ready! 🎉
Use a structured permalink format (/portfolio/%postname%/) for better SEO.
/portfolio/%postname%/
Create categories and tags for CPTs to improve content filtering.
Not all themes support CPTs out of the box; ensure your theme works with them.
Use caching and limit CPT queries to prevent slowdowns.
Use sanitize_text_field() and wp_kses() to prevent security vulnerabilities.
sanitize_text_field()
wp_kses()
If you delete a CPT from functions.php or a plugin, all associated posts become inaccessible but remain in the database.
Yes! Use Advanced Custom Fields (ACF) or add_meta_box() for extra data like pricing or dates.
add_meta_box()
Go to Appearance → Menus, find your CPT under “Custom Links,” and add it to your menu.
Yes! Elementor, Divi, and Beaver Builder allow you to design custom layouts for CPTs.
Add this code to functions.php:
function create_custom_taxonomy() { register_taxonomy( 'portfolio_category', 'portfolio', array( 'label' => 'Portfolio Categories', 'hierarchical' => true, 'rewrite' => array('slug' => 'portfolio-category'), ) ); } add_action('init', 'create_custom_taxonomy');
Custom Post Type UI is great for beginners, while Pods is ideal for advanced users needing custom fields.
Creating custom post types in WordPress enhances your website’s organization, usability, and SEO. Whether you code manually or use a plugin, CPTs give you the flexibility to create unique content structures like portfolios, events, job listings, and more.
By following best practices and using CPTs effectively, you can build a custom WordPress website that stands out and performs well! 🚀
This page was last edited on 13 March 2025, at 3:54 pm
Your email address will not be published. Required fields are marked *
Comment *
Name *
Email *
Website
Save my name, email, and website in this browser for the next time I comment.
How many people work in your company?Less than 1010-5050-250250+
By proceeding, you agree to our Privacy Policy