WordPress.org

Ready to get started?Download WordPress

Forums

Using Same Permalink With Custom Post Type (1 post)

  1. suntower
    Member
    Posted 1 year ago #

    Hi,

    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.

    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?

    TIA,

    ---JC

Topic Closed

This topic has been closed to new replies.

About this Topic