Want full control over your WordPress content structure without relying on plugins? This tutorial shows you how to create a custom post type in WordPress without a plugin—perfect for portfolios, testimonials, services, and more.
Whether you’re a beginner or intermediate developer, this Urdu/Hindi guide walks you through the process step-by-step using clean, reusable code.
Step 1: What Is a Custom Post Type in WordPress (CPT)?
Custom Post Types allow you to create content beyond the default Posts and Pages. Examples include Portfolios, Services, Events, and Medical Staff profiles. CPTs help organize your site and improve user experience.
Step 2: Why Use CPTs Without Plugins?
Using code instead of plugins keeps your site lightweight, improves performance, and gives you full control over labels, icons, and supported features. It also avoids plugin conflicts and cluttered admin panels.
Step 3: Register CPT via functions.php
Add the following code to your theme’s functions.php
file to register a new post type called “Tutorial”:
// Tutorial Custom Post Type
function Tutorial_init() {
// set up Tutorial labels
$labels = array(
‘name’ => ‘Tutorials’,
‘singular_name’ => ‘Tutorial’,
‘add_new’ => ‘Add New Tutorial’,
‘add_new_item’ => ‘Add New Tutorial’,
‘edit_item’ => ‘Edit Tutorial’,
‘new_item’ => ‘New Tutorial’,
‘all_items’ => ‘All Tutorials’,
‘view_item’ => ‘View Tutorial’,
‘search_items’ => ‘Search Tutorials’,
‘not_found’ => ‘No Tutorials Found’,
‘not_found_in_trash’ => ‘No Tutorials found in Trash’,
‘parent_item_colon’ => ”,
‘menu_name’ => ‘Tutorials’,
);// register post type
$args = array(
‘labels’ => $labels,
‘public’ => true,
‘has_archive’ => true,
‘show_ui’ => true,
‘capability_type’ => ‘post’,
‘hierarchical’ => false,
‘rewrite’ => array(‘slug’ => ‘Tutorial’),
‘query_var’ => true,
‘menu_icon’ => ‘dashicons-randomize’,
‘supports’ => array(
‘title’,
‘editor’,
‘excerpt’,
‘trackbacks’,
‘custom-fields’,
‘comments’,
‘revisions’,
‘thumbnail’,
‘author’,
‘page-attributes’
)
);
register_post_type( ‘Tutorial’, $args );// register taxonomy
register_taxonomy(‘tutorial_category’, ‘tutorial’, array(‘hierarchical’ => true, ‘label’ => ‘Category’, ‘query_var’ => true, ‘rewrite’ => array( ‘slug’ => ‘tutorial-category’ )));
}
add_action( ‘init’, ‘Tutorial_init’ );
Step 4: Customize Labels and Features
You can modify the $labels
array to match your content type (e.g., Services, Events). Change 'menu_icon'
to suit your branding using Dashicons.
Step 5: Display CPT Content on Your Theme
Use WP_Query
or get_posts()
to fetch and display your Custom Post Type in WordPress on the front-end. Example:
Need Help with Custom Post Type in WordPress Development?
If you want expert help creating custom post types, taxonomies, or theme integrations, we offer professional WordPress development services tailored for agencies, freelancers, and business websites.