Title: Custom taxonomy returning 404 error
Last modified: August 22, 2016

---

# Custom taxonomy returning 404 error

 *  [Niklas](https://wordpress.org/support/users/niklasbr/)
 * (@niklasbr)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/custom-taxonomy-404/)
 * 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)

 *  [kewski](https://wordpress.org/support/users/kewski/)
 * (@kewski)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/custom-taxonomy-404/#post-5277702)
 * Look what happens when you set the default link structure, then use permalink
   structure you want
 *  [markonikolic](https://wordpress.org/support/users/markoof/)
 * (@markoof)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/custom-taxonomy-404/#post-5277710)
 * Hi,
 * Try to re-set permalinks in Settings –> Permalinks
 *  Thread Starter [Niklas](https://wordpress.org/support/users/niklasbr/)
 * (@niklasbr)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/custom-taxonomy-404/#post-5277716)
 * Tried it on your recommendation but neither `example.com/?taxonomy=food` nor `
   example.com/food` works. 🙁
 *  Thread Starter [Niklas](https://wordpress.org/support/users/niklasbr/)
 * (@niklasbr)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/custom-taxonomy-404/#post-5277720)
 * [@markoof](https://wordpress.org/support/users/markoof/)
 * Thanks, but resetting didn’t work either, still loads the 404.php template file.
 * Worth noting is that the following URL:s _do_ work `example.com/food/taxonomy-
   term` where _taxonomy-term_ is the slug any term in the taxonomy.
 *  Thread Starter [Niklas](https://wordpress.org/support/users/niklasbr/)
 * (@niklasbr)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/custom-taxonomy-404/#post-5277725)
 * I found this article on Smashing Magazine which has a very interesting section:
   [Creating A Custom Landing Page For Taxonomy Archives](http://www.smashingmagazine.com/2014/08/27/customizing-wordpress-archives-categories-terms-taxonomies/)(
   scroll down a bit). It looks just like what I might need, but I can’t get it 
   working either:
 *     ```
       add_filter( 'taxonomy_archive ', 'slug_tax_page_one' );
       function slug_tax_page_one( $template ) {
       	if ( is_tax( 'ratt' ) ) { // 'ratt' is lowercase taxonomy name in register_taxonomy()
       		 global $wp_query;
       		 $page = $wp_query->query_vars['paged'];
       		if ( $page = 0 ) {
       			$template = get_stylesheet_directory(). '/taxonomy-food.php';
       		}
       	}
   
       	return $template;
       }
       ```
   
 *  [Tribulant Software](https://wordpress.org/support/users/contrid/)
 * (@contrid)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/custom-taxonomy-404/#post-5277898)
 * What happens when you set `hierarchical` to `false`?
    Does the 404 go away then?
 *  Thread Starter [Niklas](https://wordpress.org/support/users/niklasbr/)
 * (@niklasbr)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/custom-taxonomy-404/#post-5277926)
 * [@tribulant](https://wordpress.org/support/users/tribulant/) Software
 * Thanks for your suggestion! I tried that, then I went to the Permalinks and re-
   saved, but it still does not work.
 *  Thread Starter [Niklas](https://wordpress.org/support/users/niklasbr/)
 * (@niklasbr)
 * [11 years, 8 months ago](https://wordpress.org/support/topic/custom-taxonomy-404/#post-5277936)
 * Some clarification:
 * This works: `example.com/food/bagels` and shows all posts with the `bagels` category
   from the custom taxonomy with `food` slug.
 * However, `example.com/food` returns 404 not found.
 * This the current configuration:
 *     ```
       register_taxonomy(
       	'ratt', // taxonomy id
       	array(
       		'mat' // the content type
       	),
       	array(
       		'hierarchical' => false,
       		'labels' => array(
       			// Removed for brevity
       		),
       		'public' => true,
       		'rewrite' => array(
       			'slug' => 'food',
       		),
       	)
       );
       ```
   
 *  [typ90](https://wordpress.org/support/users/typ90/)
 * (@typ90)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/custom-taxonomy-404/#post-5278022)
 * [@niklas](https://wordpress.org/support/users/niklas/) have you figured out a
   solution? I’m getting the same issue.

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Custom taxonomy returning 404 error’ is closed to new replies.

## Tags

 * [custom taxonomy](https://wordpress.org/support/topic-tag/custom-taxonomy/)
 * [taxonomy](https://wordpress.org/support/topic-tag/taxonomy/)
 * [template tags](https://wordpress.org/support/topic-tag/template-tags/)

 * 9 replies
 * 5 participants
 * Last reply from: [typ90](https://wordpress.org/support/users/typ90/)
 * Last activity: [11 years, 7 months ago](https://wordpress.org/support/topic/custom-taxonomy-404/#post-5278022)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
