I’m looking for a way to solve my problem with permalinks in wordpress.
I have 3 post types: news (default), posttype1, posttype2
all 3 uses the standard category. I added 3 categories in it: cat1, cat2, cat3
What I want is this:
www.mywebsite.com/posttype1 : show all posts of « posttype1 »
www.mywebsite.com/posttype1/cat1 : show all posts of « posttype1 » that are in category « cat1 »
www.mywebsite.com/posttype1/cat1/post-name : show the post named « post-name » in « posttype1 » that is in category « cat1 »
and apply that rule to all 3 post types… I’ve tried almost everything about rewriting rules in function.php, but can’t find any solution. And if I put /%category%/%postname%/ in permalink settings, it actually works well for the default post type, but don’t work for both custom post types: the category is not taken into account.
I’ve tried to install the Custom Post Type Permalinks plugin, but here again the category is not taken into account.
This is actually what I have in my functions.php (for posttype1)
register_post_type(‘posttype1’, array(
'label' => __(‘Posttype1’),
'singular_label' => __(‘Posttype1’),
'public' => true,
'show_ui' => true,
'capability_type' => 'post',
'hierarchical' => true,
'menu_position' => 4,
'supports' => array('title', 'editor'),
'rewrite' => array('slug' => 'posttype1', 'with_front' => false),
'has_archive' => true,
'taxonomies' => array('category')
));