Search code examples
phpwordpresscustom-post-typetaxonomy-terms

Page not found on blog level 2 after registering taxonomy in WordPress


I have a custom post type called Resources which has been added like this:

register_post_type(
    'resources',
    tp_build_post_args(
        'resources', 'Resource', 'Resources',
        array(
            'menu_icon'     => 'dashicons-welcome-write-blog',
            'menu_position' => 20,
            'has_archive'   => true,
            'public'      => true,
            'supports' => array('editor', 'title','author','thumbnail', 'revisions'),
            'taxonomies' => array('subject', 'type', 'sector')
            //'rewrite' => array ( 'slug' => 'resources', 'with_front' => false )
        )
    )
);

And have registered this taxonomy like this:

register_taxonomy(  
    'resource', 
    'resources', 
    array(  
        'hierarchical' => false,  
    query_var' => true,
  )  
); 

On the URL /resources, the level 1 template loads fine. But, when selected an blog post from this page, it results in a 404.

When I click on a blog post, the URL is correct (i.e. /resources/test-post), so unsure on why it's resulting in a 404? My guess is that it has something to do with the taxonomies?

Other info:

  • Level 1 blog template is using: archive-resources.php
  • Level 2 blog template is using: single-resources.php

Solution

  • Please flush permalinks go to settings -> permalinks -> change to post id

    and save and again change it to what ever you like and save again.