you can try with this plugin (or see its code)
https://wordpress.org/plugins/wp-better-permalinks/
It allows you change the custom friendly permalinks structure to Custom Post Type > Taxonomy > Post and Custom Post Type > Taxonomy instead of default WordPress structure.
it Provides different permalinks structure pattern:
Custom Post Type > Single Term (or Term tree) > Post
Custom Post Type > Post (when no term is selected)
Custom Post Type > Single Term (or Term tree)
It helped me a lot with this issue…
Related Posts:
- Mixing custom post type and taxonomy rewrite structures?
- Rewriting a custom-post-type permalink with taxonomy term?
- WordPress Rewrite Rules for Custom Post Type and Taxonomy
- How to modify URL structures in custom post types and taxonomies or terms
- Create permalink structure for one taxonomy archive per custom post type
- Custom permalinks
- Permalink rewrite with custom post type and custom taxonomy
- Custom Permalinks for Custom Post Types and Taxonomies
- Including two taxonomies in a permalink structure
- WP Rewrite Rules – Custom post type & taxonomy
- Remove base slug in CPT & CT, use CT in permalink
- How to rewrite custom post type URL for multiple depths instead of one specific depth
- Custom post type category, taxonomy and URL rewrite problem
- Permalink Structure problem with cpt and custom taxonomy
- Custom Permalink Tag breaks Pagination
- Custom Permalink for Taxonimie and Custom Post Type
- multiple url slug for single custom post type
- Custom Post Type and Custom Taxonomy Permalinks
- Permalink Structure CPT With Custom Taxonomy Fails
- Change Permalink Structure for Tag.php template
- Custom taxonomy in URL showing 404
- Adding custom post category slug in permalink causes 404 error for pages and posts
- How Can I Change the Custom Post Type Slug to the Taxonomy Slug in the URL?
- Use same slug base for Custom Post Type posts, and multiple taxonomy terms
- How to create custom url structure based on custom post type rewrite slug, taxonomy and category slug?
- Customize Custom Post Type URL
- Custom Permalink to remove category word , keeping posts permalink with date?
- Custom Permalinks with CPT and Hierarchical Taxonomies
- Custom Permalink Structure for Custom Post Type, Custom Taxonomy, Under a page
- Custom taxonomy returns 404
- CPT’s with landing page instead of archive – Url Rewrite?
- Permalink structure with custom taxonomies and custom post type like /parent-tax/child-tax/custom-post-type-name (with no base name)
- Custom permalink with child taxonomy terms
- Best way to specify “article type” in URL
- Custom Post Type Advanced Slug
- WordPress custom permalink and archive link for custom post type
- Custom Permalink For Custom Post Type – Working Fine But Broken For Pagination
- Error 404 change permalink term custom term taxonomy
- Changing CPT permalink
- Pretty Permalinks with CTP and Taxonomies / Hierarchical
- Customise Permalink Structure For Custom Post Types
- % encoded URL giving 404 error in WordPress
- Parent cpt/child custom post type URL permalink relationship
- Using /%postname% for a custom post type
- Changing the URL Structure of a Paginated Custom Post
- Custom post type taxonomies URL rewrite
- Custom Posttype Inheritance (and url structure)
- register_taxonomy with multiple object type and update_count_callback
- Permalinks so that one custom post type appears to be a child of another, not working
- Understanding Permalinks on Custom Post Types
- Custom post type’s get_permalink returns wrong url
- Prepend meta_value to permalink of post
- Rewrite permalinks for custom posttype and custom taxonomy
- URL rewrite and navigation structure for wordpress custom post type
- Define permalinks for custom post type by taxonomy in WP 3.4
- Remove taxonomy slug when not assigning taxonomy with custom post types
- Custom Post Type/ Taxonomy URL rewrite
- how to get archive urls with same origin for custom types and terms?
- Permalinks for Taxonomy and Custom Post Type
- Programmatically adding posts
- How to create a permalink structure with custom taxonomies and custom post types like base-name/parent-tax/child-tax/custom-post-type-name
- Share parent path between Custom Post Types and Pages?
- Pretty URLs for Custom Post Type & Custom Taxonomy with Duplicate Slugs on WPML
- wp_list_categories() – current-cat class also inside posts?
- Custom post type url with category
- How can I use get_post_meta with add_rewrite_rule to build custom permalinks?
- Set a CPT slug as a base name for all the taxonomies
- Custom taxonomy rewrite with query var returns %2F in URL
- Remove slug in URL custom post type
- URL rewriting for CTP assigned entity
- permalink /category/post-name with custom post type and taxonomy
- Custom post type and taxonomy permalinks
- set permalink for CPT
- Ignoring slug capitalization on rewrite rule for custom post type archive page
- Taxonomy in URL
- How to solve this custom post type goes to 404 page?
- Enabling permalinks disables custom page template
- Taxonomy rewrite pagination 404
- Remove cpt slug from url and use custom taxonomy instead breaks all other cpt
- Set priority to permalinks
- How to properly set the rewrite rules for this case?
- How to fix 404 on post after prepending Custom Post Type url with Custom Taxonomy Term slug
- How to create a permalink structure with custom taxonomies and custom post types
- Template hierarchy changes when custom post-type permalink leverages custom taxonomy
- Associate custom CPT with another CPT’s taxonomy and rewrite permalinks
- Post Custom & Taxonomy 404 error
- Remove custom post type slug but keep related category taxonomy permalink
- page not found for example.com/custom-post-name
- Force WordPress to only match URL in category
- Same permalink structure for all post types?
- Custom post type with parent page? Possible?
- Hierarchical taxonomy in permalink structure
- Why won’t this rewrite rule work?
- Category / Custom Post Type permalink issue
- Adding rewrite rules to Custom Post-type mixed with Taxonomy
- Custom post type permalink structure
- How can i change url structure of cpt like this?
- Rewrite Rule for custom post type link with or without taxonomy terms
- Custom post type Premalinks main page and details page
- Permalinks for Custom Post Types and Taxonomies