0

I have created custom taxonomy like so:

CODE:

/*
* Register Product Category Taxonomy
*/
function product_category_taxonomy() {

    $labels = array(
        'name'                       => _x( 'Categories', 'Taxonomy General Name', 'textdomain' ),
        'singular_name'              => _x( 'Category', 'Taxonomy Singular Name', 'textdomain' ),
        'menu_name'                  => __( 'Categories', 'textdomain' ),
        'all_items'                  => __( 'All Items', 'textdomain' ),
        'parent_item'                => __( 'Parent Item', 'textdomain' ),
        'parent_item_colon'          => __( 'Parent Item:', 'textdomain' ),
        'new_item_name'              => __( 'New Item Name', 'textdomain' ),
        'add_new_item'               => __( 'Add New Item', 'textdomain' ),
        'edit_item'                  => __( 'Edit Item', 'textdomain' ),
        'update_item'                => __( 'Update Item', 'textdomain' ),
        'view_item'                  => __( 'View Item', 'textdomain' ),
        'separate_items_with_commas' => __( 'Separate items with commas', 'textdomain' ),
        'add_or_remove_items'        => __( 'Add or remove items', 'textdomain' ),
        'choose_from_most_used'      => __( 'Choose from the most used', 'textdomain' ),
        'popular_items'              => __( 'Popular Items', 'textdomain' ),
        'search_items'               => __( 'Search Items', 'textdomain' ),
        'not_found'                  => __( 'Not Found', 'textdomain' ),
        'no_terms'                   => __( 'No items', 'textdomain' ),
        'items_list'                 => __( 'Items list', 'textdomain' ),
        'items_list_navigation'      => __( 'Items list navigation', 'textdomain' ),
    );
    $args = array(
        'labels'                     => $labels,
        'hierarchical'               => true,
        'public'                     => true,
        'show_ui'                    => true,
        'show_admin_column'          => true,
        'show_in_nav_menus'          => true,
        'show_tagcloud'              => false,
        'rewrite'                    => array( 'slug' => 'products', 'hierarchical' => true, 'with_front' => false ),
    );
    register_taxonomy( 'product-category', array( 'product' ), $args );
    flush_rewrite_rules();
}
add_action( 'init', 'product_category_taxonomy', 0 );

WHEN I OPEN URL www.domain.com/products/subcategory everything works.

BUT WHEN I OPEN www.domain.com/products I get 404 error.

In other words I need to display archive page for created taxonomy. I have tried usual things, like flushing, saving permalink structure, but that didn't worked.

2
  • 1
    Hi, Have you refreshed your permalinks? Settings | Permalinks | Selected your preferred permalinks | Save Changes – this will update your .htaccess file.
    – user23355
    Dec 5, 2016 at 12:53
  • 1
    here is your answer wordpress.stackexchange.com/a/235452/90674
    – GKS
    Dec 5, 2016 at 12:53

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.