I am new here and I need your help because I don’t understand how to solve this.
I need to register a new custom type of “textbooks” because I want to have a different design for them and keep them separate from the rest of the posts. I also want to organize them into categories, so I will use a taxonomy for this. I read a lot of tutorials (here and from Google) and I found many ways to do this, but the result is not the one I expected. Finally, I wrote this code in the plugin:
<?php
function register_my_custom_post_type_tutorials() {
$labels = array(
'name' => 'Tutorials',
'singular_name' => 'Tutorial',
'add_new' => 'Add New',
'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'
);
$args = array(
'labels' => $labels,
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => array( 'slug' => 'tutorials' ),
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => false,
'menu_position' => null,
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments','custom-fields','page-attributes','post-formats' )
);
register_post_type( 'wizz-tutorials', $args );
}
add_action( 'init', 'register_my_custom_post_type_tutorials' );
add_action('init', 'register_tutorials_taxonomy');
function register_tutorials_taxonomy() {
register_taxonomy('wizz-tutorials-category',
'wizz-tutorials',
array (
'labels' => array (
'name' => 'Tutorials Categories',
'singular_name' => 'Tutorials Categories',
'search_items' => 'Search Tutorials Categories',
'popular_items' => 'Popular Tutorials Categories',
'all_items' => 'All Tutorials Categories',
'parent_item' => 'Parent Tutorials Category',
'parent_item_colon' => 'Parent Tutorials Category:',
'edit_item' => 'Edit Tutorials Category',
'update_item' => 'Update Tutorials Category',
'add_new_item' => 'Add New Tutorials Category',
'new_item_name' => 'New Tutorials Category',
),
'hierarchical' => true,
'show_ui' => true,
'show_tagcloud' => true,
'rewrite' => array( 'slug' => 'tuts-category' ),
'public' => true
)
);
}
?>
In the admin panel, I can now add "tutorials". I also created several categories for them (photoshop, website, etc.). The problem is that this is a bullet.
What I have at the moment:
mywebsite.com/tutorials/ - (
archive.php)
mywebsite.com/tutorials/post-name - (
single.php)
mywebsite.com/tuts-category/photoshop/ - ,
, - :
slug , , 'rewrite' => array( 'slug' => 'tutorials' ), 404 error.
? , ? !