I want to create the following permalink structure
custom post type: resources
custom taxonomy: resources-category
(e.g. Sales, Business, ...)
how can I get this structure: url.com/%resources-category%/detail-slug
e.g.url.com/sales/how-to-sale
url.com/business/how-to-something
What I get until now is, that I can open this urls, but they are automatically redirected to my custom post type resources
slug
e.g.
url.com/sales/how-to-sale
redirects to url.com/resources/how-to-sale
I registered the post type:
function registerTypeResources () {
register_post_type('resources',
array(
'labels' => array(
'name' => __('Resources'),
'singular_name' => __('Resources')
),
'public' => true,
'has_archive' => false,
'supports' => array('title', 'thumbnail', 'editor'),
'show_in_rest' => true,
)
);
}
add_action('init', 'registerTypeResources');
I've added the taxonomy:
add_action('init', 'registerRessourcesTaxonomy', 0);
function registerRessourcesTaxonomy () {
register_taxonomy(
'resources-category',
'resources',
array(
'labels' => array(
'name' => __('Categories'),
'add_new_item' => __('Add new category'),
'new_item_name' => __('New category ')
),
'show_in_rest' => true,
'show_ui' => true,
'show_tagcloud' => false,
'hierarchical' => true
)
);
}
I added a rewrite:
add_action('init', function () {
add_rewrite_rule('sales/(.+)/?$', 'index.php?resources=$matches[1]', 'bottom');
add_rewrite_rule('business/(.+)/?$', 'index.php?resources=$matches[1]', 'bottom');
});
How can I disable the redirect to resources?
Thanks for your help!