Want to create a Custom Post Type (CPT) in WordPress without using any plugin? This easy-to-follow tutorial shows you how to register a CPT using code only, giving you full control over your website structure.
๐ฏ In this video, you’ll learn:
โ
What is a custom post type
โ
When and why to use CPTs in WordPress
โ
How to register a new post type using functions.php
โ
How to show the CPT in your WordPress admin
โ
Tips to customize labels, menu icons, and support features
โ
How to display CPT content on your theme
๐ Use Case Examples:
- Portfolio
- Testimonials
- Services
- Events
- Doctors / Medical Staff
๐ฃ๏ธ Language: Urdu / Hindi
๐ป Skill Level: Beginner to Intermediate
๐ง Bonus Tip: No plugin = faster site + cleaner backend.
// 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’ );