I create a custom post type add following code in theme's functions.php
function cptarchivePost_init() {
$args = array(
'label' => 'Archive Post',
'public' => true,
'show_ui' => true,
'capability_type' => 'post',
'hierarchical' => false,
'rewrite' => array('slug' => 'cpt_archive_post'),
'query_var' => true,
'menu_icon' => 'dashicons-video-alt',
'supports' => array(
'title',
'editor',
'excerpt',
'trackbacks',
'custom-fields',
'comments',
'revisions',
'thumbnail',
'author',
'page-attributes',)
);
register_post_type( 'cpt_archive_post', $args );
}
add_action( 'init', 'cptarchivePost_init' );
add_action( 'init', 'create_cpt_archive_category', 0 );
function create_cpt_archive_category() {
register_taxonomy(
'cpt_archive_category',
'cpt_archive_post',
array(
'labels' => array(
'name' => 'Category',
'add_new_item' => 'Add Category',
'new_item_name' => "New Category"
),
'show_ui' => true,
'show_tagcloud' => false,
'hierarchical' => true
)
);
}
and create a file/template in theme with name single-cpt_archive_post.php
but still the post using index.php template
can anyone help how can I create single template for custom post