Taxonomy Url with Custom post type prefix re-write rule

I have a taxonomy called Section and a Custom post type called Developments.

What i need to achieve is a permalink on the taxonomy with custom post type prefixed: e.g:

Read More
  1. custom post type: development <- More than one custom post type so needs to be dynamic
  2. taxonomy: section
  3. term: casting

http://site.com/development/section/casting

What i have at the moment:

  1. taxonomy: section
  2. term: casting

http://site.com/section/casting

Permalink Structure:
Post name

PS* Any help will be much appreciated:

// Register Section taxonomy for Development, Pre-Production, Shooting & Post-Production
add_action( 'init', 'jh_register_taxonomy_section' );

function jh_register_taxonomy_section() {

    $labels = array(
        'name' => _x( 'Sections', 'sections' ),
        'singular_name' => _x( 'Section', 'sections' ),
        'search_items' => _x( 'Search Sections', 'sections' ),
        'popular_items' => _x( 'Popular Sections', 'sections' ),
        'all_items' => _x( 'All Sections', 'sections' ),
        'parent_item' => _x( 'Parent Section', 'sections' ),
        'parent_item_colon' => _x( 'Parent Section:', 'sections' ),
        'edit_item' => _x( 'Edit Section', 'sections' ),
        'update_item' => _x( 'Update Section', 'sections' ),
        'add_new_item' => _x( 'Add New Section', 'sections' ),
        'new_item_name' => _x( 'New Section', 'sections' ),
        'separate_items_with_commas' => _x( 'Separate sections with commas', 'sections' ),
        'add_or_remove_items' => _x( 'Add or remove sections', 'sections' ),
        'choose_from_most_used' => _x( 'Choose from the most used sections', 'sections' ),
        'menu_name' => _x( 'Sections', 'sections' ),
    );

    $args = array(
        'labels' => $labels,
        'public' => true,
        'show_in_nav_menus' => false,
        'show_ui' => true,
        'hierarchical' => true,
        'supports' => array('title', 'editor', 'excerpt', 'thumbnail'),
        'rewrite' => array('slug' => 'section', 'with_front' => true, 'hierarchical' => true),
        'query_var' => true
    );
    register_taxonomy('sections',array('development','shoot','pre_production','post_production'), $args );
}

// Register Developments custom post type
add_action('init', 'jh_register_developments');

function jh_register_developments() {

    $labels = array(
        'name' => __('Developments', 'development'),
        'singular_name' => __('Development', 'development'),
        'add_name' => __('Add New', 'development'),
        'not_found' => __('No developments found', 'development'),
        'not_found_in_trash' => __('No developments found in Trash', 'development'),
        'menu_name' => __('Development', 'development')
    );

    $args = array(
        'labels' => $labels,
        'public' => true,
        'publicly_queryable' => true,
        'has_archive' => false,
        'supports' => array('title', 'editor', 'excerpt', 'thumbnail'),
        'can_export' => true,
        'rewrite' => true,
        'menu_position' => '35',
        'capability_type' => 'post'
    );

    register_post_type('development', $args);
}

Related posts

Leave a Reply

1 comment

  1. Try changing the $args you are passing into the register_taxonomy method so that rewrite -> slug includes the development tag

    $args = array(
            'labels' => $labels,
            'public' => true,
            'show_in_nav_menus' => false,
            'show_ui' => true,
            'hierarchical' => true,
            'supports' => array('title', 'editor', 'excerpt', 'thumbnail'),
            'rewrite' => array('slug' => 'development/section', 'with_front' => true, 'hierarchical' => true),
            'query_var' => true
        );