Can’t setup nested permalink structure for custom post type’s taxonomies
-
Hi guys i have the following code and i am trying to register custom post type with custom taxonomy attached to it which implements a nested permalinks strucutre. Example with the post type blog.
I want blog posts to be available at mysite.com/blog
And the custom taxonomies which would be categories at mysite.com/blog/categories. And a few other ones which implement the same structure. The problem is that it works for the CPT, but the taxonomy page returns 404 if it has the parent post type’s slug in its permalink. If i change the taxonomy slug to not use the blog/category structure, but for example to use test/category structure it works. If anyone could help me understand how to properly implement it would be much appreaciated. Thank you// # CPT Blog
function create_post_type_blog() {
$labels = array(// My custom labels here);register_post_type( ‘blog’, array(
‘label’ => ‘Публикаци?’,
‘labels’ => $labels,
‘public’ => true,
‘has_archive’ => true,
‘supports’ => array ( ‘title’, ‘editor’, ‘thumbnail’, ‘excerpt’ ),
‘taxonomies’ => array( ‘blog_categories’, ‘blog_tags’ ),
‘rewrite’ => array( ‘slug’ => ‘blog’ )
)
);
}
add_action( ‘init’, ‘create_post_type_blog’ );// # Blog Categories
function create_blog_categories() {
$labels = array(// My custom labels here);$args = array(
‘label’ => ‘Категории’,
‘labels’ => $labels,
‘public’ => true,
‘show_ui’ => true,
‘show_admin_column’ => true,
‘rewrite’ => array( ‘slug’ => ‘blog/categories’)
);register_taxonomy(‘blog_categories’, ‘blog’, $args);
}
add_action( ‘init’, ‘create_blog_categories’ );
- The topic ‘Can’t setup nested permalink structure for custom post type’s taxonomies’ is closed to new replies.