My Permalinks are the std %postname%. I have several custom post types, eg. ‘docs’.
function docs_init() {
// create a new taxonomy
register_taxonomy(
'docs_tax',
'docs',
array(
'label' => __( 'Documentation_Tax' ),
'sort' => true,
'args' => array( 'orderby' => 'term_order' ),
'rewrite' => array( 'slug' => 'docs' )
)
);
}
I would like to be able to have duplicate slugs. Eg. I’d like to have a general Page with the slug ‘MyPage’ and then a Docs post type also with the slug ‘MyPage’. The goal is to have users be able to do this:
URL: mysite.com/mypage —- general Page
URL: mysite.com/docs/mypage —- posttype Docs
…and this does not work. If the user types /docs/mypage, the browser redirects to /mypage …even though in the post editor it shows that /docs/mypage is the URL.
I thought that since ‘with_front’ defaults to true, WordPress would distinguish between the two slugs by assigning the ‘front’ (ie. the post type.)
How can I get what I want… or is it simply mandatory to have unique slugs?
TIA,
—JC
Simple answer is that you can’t as far as the default wordpress installation goes. It’s a must to have unique slugs.
You can however mess with the Rewrite API with some custom code to hack your way around this & there aren’t any plugins(AFAIK) to help you on your way. So it’s definitely a lot easier to just force your users to unique slugs