custom post types – WordPress Taxonmy Category Links 404

Question

I was wondering whether I could get some help?

I have created a custom post type and registered a taxonomy. Please see code below. However when I visit my taxonomy links, they either 404, or redirect to a similar category from another post type.

Trying to get URL structure like:

/resource-category/parent-cat/child-cat/

which wordpress creates correct permalink, but viewing 404.

$args = [
    'label' => __( 'Resources', 'ssa' ),
    'labels' => [
        'name' => __( 'Resources', 'ssa' ),
        'singular_name' => __( 'Resources', 'ssa' ),
    ],
    'description' => '',
    'public' => true,
    'publicly_queryable' => false,
    'show_ui' => true,
    'show_in_rest' => false,
    'rest_base' => '',
    'has_archive' => true,
    'show_in_menu' => true,
    'exclude_from_search' => false,
    'capability_type' => 'post',
    'map_meta_cap' => true,
    'hierarchical' => false,
    'query_var' => true,
    'menu_icon' => 'dashicons-media-document',
    'supports' => [ 'title' ],
    'menu_position' => 4
];

register_post_type(
    'treatment-resources',
    $args
);

$taxonomy_singular="Resource Category";
$taxonomy_plural="Resource Categories";

register_taxonomy( 'resource-category', 'treatment-resources', array(
    'label'        => __( 'Resource Category', 'ssa' ),
    'rewrite'      => array( 'slug' => 'resource-category', 'hierarchical' => true, ),
    'hierarchical' => true,
    'public' => true,
    'publicly_queryable' => true,
    'exclude_from_search' => false,
    'query_var' => true,
    'has_archive' => true,
    'labels' => [
        'name' => __( $taxonomy_plural, 'ssa'),
        'singular_name' => __( $taxonomy_singular, 'ssa'),
        'search_items' =>  __("Search $taxonomy_singular", 'ssa'),
        'all_items' => __("All $taxonomy_singular", 'ssa'),
        'parent_item' => __("Parent $taxonomy_singular", 'ssa'),
        'parent_item_colon'  => __("Parent $taxonomy_singular:", 'ssa'),
        'edit_item' => __("Edit $taxonomy_singular", 'ssa'),
        'update_item' => __("Update $taxonomy_singular", 'ssa'),
        'add_new_item' => __("Add New $taxonomy_singular", 'ssa'),
        'new_item_name' => __("New $taxonomy_singular Name", 'ssa'),
    ]
) );

I’ve tried created the taxonomy template and post type archive templates but no luck, still 404 and don’t fallback to the index.php file?

Any help as to why this isn’t working?

in progress 0
Ingo Fulam 2 months 2021-05-28T18:43:44-05:00 0 Answer 0 views 0

Answer ( 1 )

    0
    2021-06-02T06:27:44-05:00

    Have you flushed the rewrite rules? Just visit the permalink settings admin page.

Leave an answer

Browse
Browse