0
votes

I have created a custom post type named "customer-stories", I was able to display the single page, but not able to display template for category template.

I want a Separate template for all the Categories. Right now its taking 404.php as the category.

This is in my functions.php:

function story_custom_post_type() {
    $labels = array(
        'name'                => __( 'customer-stories' ),
        'singular_name'       => __( 'customer-stories'),
        'menu_name'           => __( 'customer-stories'),
        'parent_item_colon'   => __( 'Parent Story'),
        'all_items'           => __( 'All Story'),
        'view_item'           => __( 'View Story'),
        'add_new_item'        => __( 'Add New Story'),
        'add_new'             => __( 'Add New'),
        'edit_item'           => __( 'Edit Story'),
        'update_item'         => __( 'Update Story'),
        'search_items'        => __( 'Search Story'),
        'not_found'           => __( 'Not Found'),
        'not_found_in_trash'  => __( 'Not found in Trash')
    );
    $args = array(
        'label'               => __( 'customer-stories'),
        'description'         => __( 'customer-stories'),
        'labels'              => $labels,
        'supports'            => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'revisions', 'custom-fields'),
        'public'              => true,
        'hierarchical'        => false,
        'show_ui'             => true,
        'show_in_menu'        => true,
        'show_in_nav_menus'   => true,
        'show_in_admin_bar'   => true,
        'has_archive'         => true,
        'can_export'          => true,
        'exclude_from_search' => false,
            'yarpp_support'       => true,
        'taxonomies'          => array('post_tag'),
        'publicly_queryable'  => true,
        'rewrite' => array( 'slug' => 'customer-stories' ),
        'capability_type'     => 'page'
);
    register_post_type( 'customer-stories', $args );
}
add_action( 'init', 'story_custom_post_type', 0 );
// Let us create Taxonomy for Custom Post Type
add_action( 'init', 'create_customer_stories_custom_taxonomy', 0 );
//create a custom taxonomy name it "type" for your posts
function create_customer_stories_custom_taxonomy() {
  $labels = array(
    'name' => _x( 'Category', 'taxonomy general name' ),
    'singular_name' => _x( 'Category', 'taxonomy singular name' ),
    'search_items' =>  __( 'Search Categories' ),
    'all_items' => __( 'All Categories' ),
    'parent_item' => __( 'Parent Category' ),
    'parent_item_colon' => __( 'Parent Category:' ),
    'edit_item' => __( 'Edit Category' ),
    'update_item' => __( 'Update Category' ),
    'add_new_item' => __( 'Add New Category' ),
    'new_item_name' => __( 'New Category Name' ),
    'menu_name' => __( 'Categories' ),
  );
  register_taxonomy('customer-stories-cat',array('customer-stories'), array(
    'hierarchical' => true,
    'labels' => $labels,
    'show_ui' => true,
    'show_admin_column' => true,
    'query_var' => true,
    'rewrite' => array( 'slug' => 'customer-stories' ),
  ));
}

I have tried taxonomy-customer-stories-cat.php, but not working. let me know what should be the file name and the php code inside the file.

Thank you.

1

1 Answers

0
votes

Have you tried resetting the permalink back to plain, if not please try it then refresh the category page?