The slug of a CPT can not be dynamic (actually no slug can be) as wordpress needs to know how to parse the URL very early in the handling of the request. You can probably change the behaviour, but you will only end with the same results that slugs have to be constant even when you implement your own parsing.
This is why your remove_cpt_slug
generates the url you expect but wordpress fails to handle it correctly.
Related Posts:
- Custom taxonomy in URL showing 404
- Using taxonomy term in CPT permalink – Pages 404’s
- Mixing custom post type and taxonomy rewrite structures?
- How to rewrite URI of custom post type?
- Rewriting a custom-post-type permalink with taxonomy term?
- Getting hierarchical custom post type permalinks to work just like pages
- Add .html (dot HTML) extension to custom post types
- Custom rewrite rules for archive page and single post
- WordPress Rewrite Rules for Custom Post Type and Taxonomy
- How to remove slug from hierarchical custom types in 3.5.2
- Custom post types – Use post_id in permalink structure
- Custom post type 404s with rewriting even after resetting permalinks
- Multiple post types – share same ReWrite slug?
- Custom post type permalink: only use %post_id% and remove %postname%
- Custom post types – Use post_id in permalink structure when using has_archive => true
- Meta_Query as a way how to setup CPT permalinks – is it a good thing?
- Rewrite custom post type rss feed links
- 404 on child page when parent page slug is identical to custom post type
- Using /%postname% for a custom post type
- Changing the URL Structure of a Paginated Custom Post
- How to modify URL structures in custom post types and taxonomies or terms
- Adding meta values to permalink
- rewrite get parameter with custom post type
- Hierachical Custom post types permalinks not working
- How can i avoid the permalink start with ‘blog’ while using the custom post type?
- Custom Posttype Inheritance (and url structure)
- Permalinks so that one custom post type appears to be a child of another, not working
- Create permalink structure for one taxonomy archive per custom post type
- Slug for custom post type archive
- Custom permalinks
- Permalink rewrite with custom post type and custom taxonomy
- Custom post type permalink changing itself every other change
- Make permalinks based on an ACF-field
- Child pages on hierarchical Custom Post Types 404s
- Remove unwanted part of permalink custom structure from CPT url?
- Custom post type’s get_permalink returns wrong url
- Prepend meta_value to permalink of post
- Custom Permalinks for Custom Post Types and Taxonomies
- Removing parent slug from URL on custom post type
- Permalinks for CPT breaks permalinks to pages
- Including two taxonomies in a permalink structure
- WP Rewrite Rules – Custom post type & taxonomy
- URL rewrite and navigation structure for wordpress custom post type
- Changing a custom post type “has_archive” after registered
- Removing CPT slug from URL results in 404 error for archive page
- Remove Slug from Custom Post Type results in 404
- 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
- how to use two permalinks for one custom post type
- Rewrite on custom post type permalink not working?
- Custom Taxonomy 404
- WordPress Rewrite rule for nested post types
- Custom Post Type slug same as page name causing a conflict
- Custom Permalink Tag breaks Pagination
- Custom Permalink with Dynamic Taxonomy for Custom Post Type – Works, but breaks other permalinks
- Custom Post Type rewrite rules not working, how to alter the rewrite order?
- Custom Permalink for Taxonimie and Custom Post Type
- Permalinks for Taxonomy and Custom Post Type
- custom post type and custom taxonomy url conflict
- Share parent path between Custom Post Types and Pages?
- multiple url slug for single custom post type
- Custom Post Type and Custom Taxonomy Permalinks
- Change URL of posts and also Custom Post Type
- remove permalink “front part” for custom post type
- Permalink Structure CPT With Custom Taxonomy Fails
- Change Permalink Structure for Tag.php template
- Bizarre Permalinks Issue: 404 Errors Everywhere
- Making a custom help center page
- Add archive slug to default post post type
- Custom Post type and permalink settings
- Rewrite rules for custom posts types
- 404 Issue w/ Custom Post Type – using Meta for Permalink rewrite
- How to change custom post type permalink structure
- Help with Elementor Pagination CPT archive 404 problem
- Adding custom post category slug in permalink causes 404 error for pages and posts
- How can I use get_post_meta with add_rewrite_rule to build custom permalinks?
- Can’t get custom rewrite tag, query var, permastruct (permalink structure), and rewrite rule to work properly together
- 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?
- How can achieve this permalink perfectly? domain.com/%category%/%post-name%
- WordPress custom post type permalink rewrite shows page not found
- How to add rewrite rule to custom post type with parent in url with cpt ui?
- Custom post type as home page with custom url
- Customize Custom Post Type URL
- Custom post URL 404 error
- URL rewrite add author as base
- Custom Permalink to remove category word , keeping posts permalink with date?
- Set a CPT slug as a base name for all the taxonomies
- Custom Permalinks with CPT and Hierarchical Taxonomies
- Custom Permalink Structure for Custom Post Type, Custom Taxonomy, Under a page
- Custom taxonomy returns 404
- Parent Page and Breadcrumb URL’s for Custom Post Types Not Working
- Custom post type archive pagination 404
- CPT’s with landing page instead of archive – Url Rewrite?
- Custom post type permalink tag 404
- Permalink structure with custom taxonomies and custom post type like /parent-tax/child-tax/custom-post-type-name (with no base name)
- Hierarchical permalinks for custom post type and taxonomy