Custom taxonomy returning 404 error
-
I have this custom post type:
add_action( 'init', 'ddcustom_create_post_types' ); function ddcustom_create_post_types() { register_post_type( 'mat', array( 'has_archive' => true, 'labels' => array( 'name' => __( 'Food', 'dd-custom' ), 'singular_name' => __( 'Food', 'dd-custom' ), 'menu_name' => _x( 'Foods', 'admin menu', 'dd-custom' ), 'name_admin_bar' => _x( 'Food', 'add new on admin bar', 'dd-custom' ), 'add_new' => _x( 'Add new', 'mat', 'dd-custom' ), 'add_new_item' => __( 'Add new food', 'dd-custom' ), 'new_item' => __( 'New food', 'dd-custom' ), 'edit_item' => __( 'Edit food', 'dd-custom' ), 'view_item' => __( 'View food', 'dd-custom' ), 'all_items' => __( 'All foods', 'dd-custom' ), 'search_items' => __( 'Search foods', 'dd-custom' ), 'parent_item_colon' => __( 'Parent foods:', 'dd-custom' ), 'not_found' => __( 'No foods found.', 'dd-custom' ), 'not_found_in_trash' => __( 'No foods found in Trash.', 'dd-custom' ) ), 'menu_icon' => 'dashicons-cart', 'public' => true, 'rewrite' => array( // Prefixing with "dd-" to avoid clash with taxonomy which is used primarily 'slug' => 'dd-food' ), 'supports' => array( 'title', 'editor', 'thumbnail', 'excerpt', ), ) );
And then I register the following taxonomy:
add_action( 'init', 'ddcustom_content_taxonomy' ); function ddcustom_content_taxonomy() { register_taxonomy( 'ratt', 'mat', array( 'hierarchical' => true, 'labels' => array( 'name' => _x( 'Food type', 'taxonomy general name', 'dd-custom' ), 'singular_name' => _x( 'Food type', 'taxonomy singular name', 'dd-custom' ), 'search_items' => __( 'Search food types', 'dd-custom', 'dd-custom' ), 'all_items' => __( 'All food types', 'dd-custom' ), 'parent_item' => __( 'Parent food type', 'dd-custom' ), 'parent_item_colon' => __( 'Parent food type:', 'dd-custom' ), 'edit_item' => __( 'Edit food type', 'dd-custom' ), 'update_item' => __( 'Update food type', 'dd-custom' ), 'add_new_item' => __( 'Add new food type', 'dd-custom' ), 'new_item_name' => __( 'New food type name', 'dd-custom' ), 'menu_name' => __( 'Food types', 'dd-custom' ), ), 'rewrite' => array( 'slug' => 'food' ), ) ); }
The permalink structure is as follows:
/%category%/%postname%/
However, visiting example.com/food only loads the 404.php page. What am I doing wrong? Edit: the taxonomy is not empty, I have a few posts tagged in the taxonomy.
Viewing 9 replies - 1 through 9 (of 9 total)
Viewing 9 replies - 1 through 9 (of 9 total)
- The topic ‘Custom taxonomy returning 404 error’ is closed to new replies.