Followings are the codes I added in my theme function.php file

// Taxonomy Resource
$labels = array(
    'name'              => 'Resources',
    'singular_name'     => 'Resource',
    'search_items'      => 'Search Resource',
    'all_items'         => 'All Resource',
    'parent_item'       => 'Parent Resource',
    'parent_item_colon' => 'Parent Resource:',
    'edit_item'         => 'Edit Resource',
    'update_item'       => 'Update Resource',
    'add_new_item'      => 'Add New Resource',
    'new_item_name'     => 'New Resource Name',
    'menu_name'         => 'Resource',

$args = array(
    'hierarchical'      => true,
    'labels'            => $labels,
    'show_ui'           => true,
    'show_admin_column' => true,
    'query_var'         => true,
    'rewrite'           => array( 'slug' => 'resource', 'with_front' => false ),

register_taxonomy( 'resource', array( 'post' ), $args );

and I used the following line of code to display it in front-end

<?php echo get_the_term_list( $post->ID, 'resource', 'Resource: ', ', ' ); ?>

When I click the resource items in front end, it leads to a url like this: http://site-name/resource/test/

But instead of showing the default archive template, it shows a 404 page. After that I created taxonomy-resource.php file and copied the codes from archrive.php

And the result is same, it gives a 404 page.

up vote 4 down vote accepted

You can add flush_rewrite_rules() after registering your custom taxonomy.

NOTE: Flush rules only on activation or deactivation, or when you know that the rewrite rules need to be changed. Don't do it on any hook that will triggered on a routine basis. More detail information in the comments on WP Engineer's post: Custom Post Type and Permalink


You can go to Settings → Permalinks → Save Permalinks, that should flush the rewrite rules manually.

  • Hi thank you so much. The second option fixed everything. I spend two days to find the error. Just clicking the save button in Permalink fixed it, Again thank you so much :) – Muhammad Russell Dec 23 '16 at 17:09

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.