Custom post type custom taxonomy not found

I created a custom post type on my site called Homes, which is working correctly. I created a custom taxonomy to go with it named Availability Category, and a category within that named Available Now. The taxonomy shows up in my WordPress back end, but when I go view the category at homes/available-now, I get a 404 error.

Here is the code for my custom post type:

Read More
register_post_type( 'Homes',
    array(
        'labels' => array(
            'name' => __( 'Homes' ),
            'singular_name' => __( 'Homes Item' ),
            'add_new_item' => __('Add New Homes Item'),
            'edit_item' => __('Edit Homes Item'),
            'new_item' => __('New Homes Item'),
        ),
        'supports' => array('title', 'thumbnail', 'editor'),
        'taxonomies' => array('homes-category'),
        'public' => true,
        'has_archive' => false,
        'show_in_nav_menus'   => TRUE,
        'show_in_menu'        => TRUE,
        'rewrite' => array( 
            'slug' => 'homes',
            'with_front' => false,
            'hierarchical' => false,

            ),
    )
);

And the code for my custom taxonomy:

register_taxonomy(
    'homes-category',
    'homes',
    array(
        'hierarchical' => true,
        'label' => __( 'Availability Category' ),
        'rewrite' => array(
            'slug' => 'homes',
            'with_front' => false,
        ),
    )
);

Can anyone help with this? I’ve searched for hours for a fix and nothing I have tried so far has worked. Any help would greatly be appreciated.

Related posts

Leave a Reply

4 comments

  1. The problem is that you have assigned the same rewrite slug for the custom post type “homes” as the taxonomy “homes-category”.

    To fix your problem, simply change your code for registering the custom post type to this:

    register_post_type( 'Homes',
        array(
            'labels' => array(
                'name' => __( 'Homes' ),
                'singular_name' => __( 'Homes Item' ),
                'add_new_item' => __('Add New Homes Item'),
                'edit_item' => __('Edit Homes Item'),
                'new_item' => __('New Homes Item'),
            ),
            'supports' => array('title', 'thumbnail', 'editor'),
            'taxonomies' => array('homes-category'),
            'public' => true,
            'has_archive' => false,
            'show_in_nav_menus'   => TRUE,
            'show_in_menu'        => TRUE,
            'rewrite' => array(
                'slug' => 'home', //remove the "s" so that it's not fighting with Taxonomy
                'with_front' => false,
                'hierarchical' => false,
    
                ),
        )
    );
    

    Then revisit your Permalink page, and try again. What’s good now, is that you also regain the ability to create a Page called “homes” again, with which you could create a custom template for. I’ve tested all of this and it works. 🙂

  2. Check to see if you have any conflicting pages / posts using the same slug (ie: did you create a page with the name “homes”?). If you did, delete them and be sure to empty the trash as well.

  3. I’ve the same problem. I did a custom post type “products” and custom taxonomy “products” and that cost me an 404 error when i was trying to reach http://www.domain.com/products. The address http://www.domain.com/products/product-01 was ok.

    So you have to rename your custom post type to “product” and the CTP to “products” so they are different. First delete the custom post type and the custom taxonomy. Then register your new CPT and CTP
    with DIFFERENT names !!!

    CPT – custom post type
    CTP – custom taxonomy type