WordPress.org

Ready to get started?Download WordPress

Forums

404 errors for Hierarchical Custom Taxonomies (1 post)

  1. katmac_aus
    Member
    Posted 2 years ago #

    I'm using custom taxonomies (product categories) for a custom post type (products) . I had experienced some conflicts with my pages and permalink structure and found this was causing 404 errors. So I have my taxonomy structure as follows:

    register_taxonomy('my_categories',
    array (
    0 => 'my_products',
    ),
    array(
    'hierarchical' => true,
    'label' => 'Product Categories',
    'show_ui' => true,
    'query_var' => true,
    'rewrite' => array(
    'slug' => 'products',
    'with_front' => false,
    'hierarchical' => true
    ),
    'singular_label' => 'Category')
    );

    Original I had the slug as blank but this caused my pages to return 404 errors. So by adding in 'products' as the slug this issue is solved.

    The permalink structure I am using is: /%category%/%postname%/

    I can view my pages, the product archive and individual products. My custom taxonmies go 3 levels deep. For example:

    - Mens > Casual > Tops

    I can view any category at the third tier. Eg mysite.com/products/mens/casual/tops works. However mysite.com/products/mens/casual/ or mysite.com/products/mens/ returns a 404 error.

    Interestingly if I 'fake' the address eg mysite.com/products/z/z/mens by putting in 'z/z/' (or anything with 2 slashes) it then works and returns the category with all the matching results.

    If I set 'hierarchical' => false then no categories work at all.

    Any help greatly appreciated.

Topic Closed

This topic has been closed to new replies.

About this Topic