Custom Post type & Taxonomy 404

I’ve created a custom post type & taxonomy, however when I go to my taxonomy page it throws a 404 error and I can’t understand why.

// Register Custom Post Type
function portfolio_post_type() {
register_taxonomy_for_object_type(‘category’,’portfolio’);
register_post_type( ‘portfolio’,
array(
‘labels’ => array(
‘name’ => __(‘Portfolio’),
‘singular_name’ => __(‘Portfolio’),
‘add_new’ => __(‘Add new item’),
‘add_new_item’ => __(‘Add new item’),
‘edit’ => __(‘Edit’),
‘edit_item’ => __(‘Edit item’),
‘new_item’ => __(‘New item’),
‘view’ => __(‘View item’),
‘view_item’ => __(‘View item’),
‘search_items’ => __(‘Search portfolio’),
‘not_found’ => __(‘No portfolio items found’),
‘not_found_in_trash’ => __(‘No portfolio items found in trash’),
),
‘public’ => true,
‘rewrite’ => array(‘slug’ => ‘portfolio’),
‘publicly_queryable’ => true,
‘hierarchical’ => false,
‘has_archive’ => true,
‘menu_icon’ => ‘dashicons-art’,
‘supports’ => array(‘title’, ‘editor’, ‘excerpt’, ‘thumbnail’, ‘revisions’,’author’),
‘can_export’ => true,
‘taxonomies’ => array(‘portfolio-category’),
)
);
}
add_action( ‘init’, ‘portfolio_post_type’, 0 );

function portfolio_create_taxonomy() {
register_taxonomy(
‘portfolio-category’,
‘portfolio’,
array(
‘label’ => __( ‘Category’ ),
‘rewrite’ => array( ‘slug’ => ‘category’ ),
‘hierarchical’ => true,
)
);
}
add_action( ‘init’, ‘portfolio_create_taxonomy’ );

When I click to view a taxonomy it takes me to http://domain.local/category/all/

However it throws the 404 page template.

Read more here:: Custom Post type & Taxonomy 404

Leave a Reply

Your email address will not be published. Required fields are marked *