Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have 2 custom post type registered in my functions file, sectors and projects. There are pages with the same name and hence URL in both post type. My problem is that WordPress wont allow the same URL's for a page, these URL's are a requirement so need to find a fix.

Example:

Sectors

  • Apples (apples)
  • Oranges (oranges)
  • Bananas (bananas)

Projects

  • Apples (apples-2)
  • Oranges (oranges-2)
  • Bananas (bananas-2)

Code

register_post_type( 'Sectors',
    array(
        'labels' => array(
            'name' => __( 'Sectors' ),
            'singular_name' => __( 'Sector' )
        ),
    'public' => true,
    'rewrite' => array('slug' => 'sector'),
    'has_archive' => false,
    'hierarchical' => true,
    'capability_type' => 'page',
    'supports' => array('title','editor','thumbnail','page-attributes'),
    'menu_icon' => get_template_directory_uri().'/images/wordpress/cpt-sectors.png'
    )
);

register_post_type( 'Projects',
    array(
        'labels' => array(
            'name' => __( 'Projects' ),
            'singular_name' => __( 'Project' )
        ),
    'public' => true,
    'rewrite' => array('slug' => 'project'),
    'has_archive' => false,
    'hierarchical' => true,
    'capability_type' => 'page',
    'supports' => array('title','editor','thumbnail','page-attributes'),
    'menu_icon' => get_template_directory_uri().'/images/wordpress/cpt-projects.png'
    )
);

I need a way for this to work, and I am hoping there is a simple answer that I have missed in my hours of Googling.

Note: Please refrain from just posting "This cant be done" or any elongated/messy solutions like hacking the core. There must be a way for WordPress to allow this.

share|improve this question
    
This is only a problem if your post types have "hierarchical" set to true. IS it possible to set your post types to not be hierarchical? –  Matthew Boynes May 23 '13 at 20:38
    
Also, for reference: core.trac.wordpress.org/ticket/18962 –  Matthew Boynes May 23 '13 at 21:46
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.