I create a tour
custom post type and destination
custom taxonomy like this:
<?php
/*********************************************** Create Post Type ***********************************************/
add_action('init', 'create_post_type');
function create_post_type()
{
register_post_type('tour', array(
'label' => 'تور',
'description' => '',
'public' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_in_admin_bar' => true,
'capability_type' => 'post',
'hierarchical' => true,
'rewrite' => array('slug' => 'tour', 'with_front' => false,'hierarchical' => true,),
'query_var' => true,
'has_archive' => false,
'exclude_from_search' => false,
'supports' => array('title', 'editor', 'thumbnail'),
'taxonomies' => array('destination'),
'labels' => array(
'name' => 'تور',
'singular_name' => 'تور',
'menu_name' => 'تور',
'add_new' => 'افزودن تور',
'add_new_item' => 'افزودن تور',
'edit' => 'ویرایش',
'edit_item' => 'ویرایش تور',
'new_item' => 'تور جدید',
'view' => 'نمایش',
'view_item' => 'نمایش',
'search_items' => 'جستجوی تور',
'not_found' => 'تور وجود ندارد.',
'not_found_in_trash' => 'زباله خالی است.',
'parent' => 'تور والد',
),
'menu_icon' => 'dashicons-admin-site-alt'
));
}
/*********************************************** Register Taxonomy ***********************************************/
add_action('init', 'site_register_taxonomy');
function site_register_taxonomy()
{
register_taxonomy(
'destination',
array('tour'),
array(
'labels' => array(
'name' => 'مقصد',
'all_items' => 'همه انواع مقاصد',
'edit_item' => 'ویرایش مقصد',
'update_item' => 'آپدیت مقصد',
'add_new_item' => 'اضافه کردن مقصد جدید',
),
'sort' => true,
'args' => array('orderby' => 'term_order'),
'rewrite' => array('slug' => 'tour', 'with_front' => false,'hierarchical' => true,),
'show_admin_column' => true,
'show_in_rest' => false,
'hierarchical' => true,
)
);
}
I want this URL structure for taxonomy and single posts:
taxonomy: site/tour/parent-tax/child-tax
post: site/tour/parent-tax/child-tax/single-post-url
now I make taxonomy structure but it gets 404 error and I don't know how to make single post url structre.
Does anyone have a solution for this?