How To Flush Permalink Structure in WordPress When Using custom Taxonomies …or what to do when WordPress custom Taxonomies show A 404 Page

I have faced many times that permalink for custom taxonomy wont work, rather it shows a 404 error page.
Suppose you have custom taxonomy named as video and want to display a link as but it shows page not found. I have listed some of the ideas to make that workable:

We can create and/or register custom taxonomies like following. We may have multiple taxonomies.

add_action('init', 'create_custom_taxonomy');
function create_custom_taxonomy (){
      'hierarchical' => false,
      'label' =>Videos ',
      'query_var' => videos,
      'rewrite' => array('slug'=>videos)

In theme directory we can create a php file as “taxonomy.php” or “taxonomy- videos.php” file. This will handle the custom taxonomy requests. We can get the idea of creating different taxonomy templates from
To make the taxonomy permalink workable we can follow the following points:
Visit the Admin >> Settings >> Permalinks and click on save changes
In functions.php file inside your theme put the below code:

add_action('init', 'custom_taxonomy_flush_rewrite');
function custom_taxonomy_flush_rewrite() {
	global $wp_rewrite;

Sometime the first method only doesn’t work and we need to work in both ways.
Some of the ideas from:



2 Comment

  1. anmari says: Reply


    one should not advise people to flush on every page load (eg: on init) – could slow down teh whole website.


  2. Irvan says: Reply

    I was a long time looking for it ..
    permalink issue is confusing to me ..
    but I find the right solutions and work on my web
    thank you for this great article.

Leave a Reply