Change 'public' => false,
to 'public' => true,
when using register_taxonomy()
. Also, don’t use capital letters for the post type name in register_post_type()
. Here’s the full updated code (make sure to save permalinks after updating your code):
add_action( 'init', 'create_project_taxonomies', 0 );
add_action( 'init', 'create_posttype' );
function create_posttype() {
$args = array(
'labels' => array('name'=>__('Projects'), 'singular_name'=>__('Projects') ),
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => array( 'slug' =>'projects','with_front'=>true ),
'capability_type' => 'post',
'has_archive' => true,
'hierarchical' => false,
'menu_position' => null,
'supports' => array( 'title', 'editor', 'author', 'thumbnail', 'excerpt', 'comments'),
'taxonomies' => array( 'project_category','post_tag'),
);
register_post_type( 'projects', $args );
}
function create_project_taxonomies() {
$labels = array(
'name' => _x( 'Project category', 'taxonomy general name', 'twentyfifteen' ),
'singular_name' => _x( 'Project catgeory', 'taxonomy singular name', 'twentyfifteen' ),
'search_items' => __( 'Search category', 'twentyfifteen' ),
'popular_items' => __( 'Popular Writers', 'twentyfifteen' ),
'all_items' => __( 'All Category', 'twentyfifteen' ),
'parent_item' => null,
'parent_item_colon' => null,
'edit_item' => __( 'Edit category', 'textdomain' ),
'update_item' => __( 'Update catrgory', 'textdomain' ),
'add_new_item' => __( 'Add New category', 'textdomain' ),
'new_item_name' => __( 'New category Name', 'textdomain' ),
'separate_items_with_commas' => __( 'Separate writers with commas', 'textdomain' ),
'add_or_remove_items' => __( 'Add or remove category', 'textdomain' ),
'choose_from_most_used' => __( 'Choose from the most used writers', 'textdomain' ),
'not_found' => __( 'No category found.', 'textdomain' ),
'menu_name' => __( 'Project Category', 'textdomain' ),
);
$args = array(
'hierarchical' => true,
'labels' => $labels,
'public' => false,
'show_ui' => true,
'show_admin_column' => true,
'update_count_callback' => '_update_post_term_count',
'query_var' => true,
'rewrite' => array( 'slug' => 'project_category'),
);
register_taxonomy( 'project_category', 'projects', $args );
}
Using a singular name for post type and category names is also a good guideline, but not a requirement.