Create Custom Post Type with Category in WordPress without plugin
<?php function news_custom_post() { $args = array( 'labels' => array( 'name' => 'Custom Post', 'singular_name' => 'custom', ), 'hierarchical' => true, 'public' => true, 'has_archive' => true, 'menu_icon' => 'dashicons-welcome-write-blog', 'supports' => array('title', 'editor', 'thumbnail'), ); register_post_type('custom post', $args); } add_action('init', 'news_custom_post'); ?>
Syntax:
<?php function function-name() { $args = array( 'labels' => array( 'name' => 'Any Custom-Post-Name', 'singular_name' => 'singular-name of Custom-Post-Name', ), 'hierarchical' => true, 'public' => true, 'has_archive' => true, 'menu_icon' => 'dashboard wordpress icon shortcode', 'supports' => array('title', 'editor', 'thumbnail'), ); register_post_type('Any Custom-Post-Name', $args); } add_action('init', 'function-name'); ?>
Output: