Don’t really know why but here is a working solution :
$blogCategoryBaseSlug = 'articles';
$labels = array(
'name' => __( 'Blog Post', 'Post Type General Name', $this->text_domain ),
'singular_name' => __( 'Blog Post', 'Post Type Singular Name', $this->text_domain ),
'menu_name' => __( 'Blog Posts', $this->text_domain ),
'name_admin_bar' => __( 'Blog Post', $this->text_domain ),
'archives' => __( 'Blog Post Archives', $this->text_domain ),
'parent_item_colon' => __( 'Parent Blog Post:', $this->text_domain ),
'all_items' => __( 'All Blog Posts', $this->text_domain ),
'add_new_item' => __( 'Add Blog Post', $this->text_domain ),
'add_new' => __( 'Add New', $this->text_domain ),
'new_item' => __( 'New Blog Post', $this->text_domain ),
'edit_item' => __( 'Edit Blog Post', $this->text_domain ),
'update_item' => __( 'Update Blog Post', $this->text_domain ),
'view_item' => __( 'View Blog Post', $this->text_domain ),
'search_items' => __( 'Search Blog Post', $this->text_domain ),
'not_found' => __( 'Not found', $this->text_domain ),
'not_found_in_trash' => __( 'Not found in Trash', $this->text_domain ),
'featured_image' => __( 'Featured Image', $this->text_domain ),
'set_featured_image' => __( 'Set featured image', $this->text_domain ),
'remove_featured_image' => __( 'Remove featured image', $this->text_domain ),
'use_featured_image' => __( 'Use as featured image', $this->text_domain ),
'insert_into_item' => __( 'Insert into Blog Post', $this->text_domain ),
'uploaded_to_this_item' => __( 'Uploaded to this Blog Post', $this->text_domain ),
'items_list' => __( 'Blog Posts list', $this->text_domain ),
'items_list_navigation' => __( 'Blog Posts list navigation', $this->text_domain ),
'filter_items_list' => __( 'Filter Blog Posts list', $this->text_domain ),
);
$args = array(
'label' => __( 'Blog Post', $this->text_domain ),
'description' => __( 'Replacement for text post', $this->text_domain ),
'labels' => $labels,
'supports' => array( 'title', 'editor', 'excerpt', 'author', 'thumbnail', 'comments', 'trackbacks', 'revisions', 'custom-fields', 'page-attributes', 'post-formats', ),
'taxonomies' => array( 'blog_post_category', 'blog_post_tag'),
'hierarchical' => false,
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'menu_position' => 5,
'show_in_admin_bar' => true,
'show_in_nav_menus' => true,
'can_export' => true,
'has_archive' => $blogCategoryBaseSlug,
'exclude_from_search' => false,
'publicly_queryable' => true,
'capability_type' => 'post',
'rewrite' => array(
'slug' => $blogCategoryBaseSlug.'/%blog_post_category%',
'with_front' => false
)
);
register_post_type( 'blogpost', $args );
$genre_args = array(
'labels' => array(
'name'=> __('Categories', 'taxonomy general name', $this->text_domain),
'singular_name' => __('Category', 'taxonomy singular name', $this->text_domain),
'search_items' => __('Search Categories', $this->text_domain),
'popular_items' => __('Popular Categories', $this->text_domain),
'all_items' => __('All Categories', $this->text_domain),
'edit_item' => __('Edit Category', $this->text_domain),
'update_item' => __('Update Category', $this->text_domain),
'add_new_item' => __('Add New Category', $this->text_domain),
'new_item_name' => __('New Category Name', $this->text_domain),
'separate_items_with_commas' => __('Seperate Categories with Commas', $this->text_domain),
'add_or_remove_items' => __('Add or Remove Categories', $this->text_domain),
'choose_from_most_used' => __('Choose from Most Used Categories', $this->text_domain)
),
'public' => true,
'show_in_nav_menus' => true,
'hierarchical' => true,
'query_var' => true,
'rewrite' => array(
'with_front' => false,
'hierarchical' => true,
'slug' => $blogCategoryBaseSlug
)
);
register_taxonomy('blog_post_category', 'blogpost', $genre_args);
add_rewrite_rule(
$blogCategoryBaseSlug.'/([^/]+)/page/([0-9]+)/?$',
'index.php?blog_post_category=$matches[1]&paged=$matches[2]',
'top'
);
add_rewrite_rule(
$blogCategoryBaseSlug.'/(.+?)/([^/]+)(?:/([0-9]+))?/?$',
'index.php?blog_post_category=$matches[1]&blogpost=$matches[2]&paged=$matches[3]',
'top'
);
But there is still an issue concerning the rewrite rules … So far, about everything is working :
site.com/articles= OK
site.com/articles/page/2 = OK
site.com/articles/category = OK
site.com/articles/category/page/2 = OK
site.com/articles/category/article-name = OK
But if i create a subcategory, it doesn’work :
site.com/articles/category/subcategory = 404 (looking for a post and not a sub category)
Is there any solution in the rewrite rules to fix that ?