I have created custom post type dart and Currently, The permalink looks like this: http://example.com/dart/%postname%/
but i want like this: http://example.com/docs/dart/custom-taxonomy/%postname%/
( docs/dart/%dart-level%/%post-name%/ )
Custom Post Type : dart
Custom taxonomy : dart-level
I'm able to add taxonomy but how to add 'docs' word before dart
here is my code:
function tbc_post_type_dart_doc()
{
$supports = array(
'title',
'editor',
'author',
'thumbnail',
'excerpt',
'post-formats',
);
$labels = array(
'name' => _x('Dart Docs', 'plural'),
'singular_name' => _x('Dart Doc', 'singular'),
'menu_name' => _x('Dart Docs', 'admin menu'),
'name_admin_bar' => _x('Dart Docs', 'admin bar'),
'add_new' => _x('Add New Dart Doc', 'add new'),
'add_new_item' => __('Add New Dart Doc'),
'new_item' => __('New Dart Doc'),
'edit_item' => __('Edit Dart Doc'),
'view_item' => __('View Dart Doc'),
'all_items' => __('All Dart Docs'),
'search_items' => __('Search Dart Docs'),
'not_found' => __('No Dart Documentation Found.'),
);
$args = array(
'supports' => $supports,
'labels' => $labels,
'public' => true,
'query_var' => true,
'show_ui' => true,
'publicly_queryable' => true,
'rewrite' => array(
'with_front' => false,
'slug' => 'dart'),
'has_archive' => "dart",
'hierarchical' => true,
'show_in_rest' => true,
'supports' => array('title', 'editor', 'thumbnail'),
'taxonomies' => array( 'dart-level' ),
'menu_icon' => 'dashicons-media-document',
);
register_post_type('dart-doc', $args);
register_taxonomy(
"dart-level",
array("dart-doc"),
array(
"hierarchical" => true,
'show_in_rest' => true,
'show_ui' => true,
'query_var' => true,
'public' => true,
'publicly_queryable' => true,
'labels' => array(
'name' => "Dart Levels",
'singular_name' => "Dart Level",
'search_items' => __( 'Search Dart Levels' ),
'all_items' => __( 'All Dart Levels' ),
'parent_item' => __( 'Parent Dart Level' ),
'parent_item_colon' => __( 'Parent Dart Level:' ),
'edit_item' => __( 'Edit Dart Level' ),
'update_item' => __( 'Update Dart Level' ),
'add_new_item' => __( 'Add New Dart Level' ),
'new_item_name' => __( 'New Dart Level Name' ),
'menu_name' => __( 'Dart Levels' ),
),
"rewrite" => array(
'slug' => 'dart',
'with_front'=> false,
)),
);
}
add_action('init', 'tbc_post_type_dart_doc', 0);