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.

Your Answer

 
discard

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.