This is far from trivial. URL processing is not straightforward and mostly buried in WP->parse_request()
which is not popular to reuse.
There is more useful url_to_postid()
function, but it’s limited to posts and does not process URL to other things.
If really necessary this would take fork of that function to deal with terms. However more practical solution would probably be to pass some extra data in some form and don’t mess with URL at all.
Related Posts:
- Custom Post Types, URL rewrite on multiple CPTs
- Taxonomy in URL
- Custom Post Type URL Rewrite’s
- Force WordPress to only match URL in category
- Customize category URL
- Custom Post Type with multiple Custom Taxonomies / Hide Taxonomy Slug from URL
- Custom post type with custom taxonomies structure url not working archive of CPT
- Rewriting a custom-post-type permalink with taxonomy term?
- Custom Post Type and Taxonomy URL rewrite
- How can I rewrite URLs to pass taxonomy and post type values to the query?
- Archive page with multiple taxonomies rewrite
- Custom post type taxonomies URL rewrite
- WordPress custom taxonomy URL rewrite on spelling errors
- Create permalink structure for one taxonomy archive per custom post type
- Custom permalinks
- WordPress Custom Post Type Category Page
- Issues when rewrite rules collide?
- Best Way to Leverage Custom Post Type Related Content and Consider SEO
- Custom Permalinks for Custom Post Types and Taxonomies
- Display CPT taxonomies as an archive page
- Including two taxonomies in a permalink structure
- WP Rewrite Rules – Custom post type & taxonomy
- Many to Many Taxonomies or rewrite rules?
- Remove base slug in CPT & CT, use CT in permalink
- Custom post type category, taxonomy and URL rewrite problem
- remove post-name from title in custom post type
- How do I list terms of a custom taxonomy at i.e. domain.com/brands/
- Permalink Structure problem with cpt and custom taxonomy
- Custom Taxonomy 404
- Custom Post Type/ Taxonomy URL rewrite
- Bulk 301 redirect for custom post type
- Custom Permalink Tag breaks Pagination
- Custom Permalink for Taxonimie and Custom Post Type
- Rewrite Custom Post Type URL slug
- how to get archive urls with same origin for custom types and terms?
- multiple url slug for single custom post type
- custom taxonomy and custom post type url conflict
- Pretty URLs for Custom Post Type & Custom Taxonomy with Duplicate Slugs on WPML
- Custom Post Type and Custom Taxonomy Permalinks
- Permalink Structure CPT With Custom Taxonomy Fails
- Conditionally custom post type url rewrite
- Query var removed after rewrite
- Change Permalink Structure for Tag.php template
- Custom Post type and permalink settings
- wp_list_categories() – current-cat class also inside posts?
- Adding custom post category slug in permalink causes 404 error for pages and posts
- How to create custom url structure based on custom post type rewrite slug, taxonomy and category slug?
- How can I make the slug of the taxonomy also the slug of the custom post
- Customize Custom Post Type URL
- How do I change the custom taxonomy slug to be the same as the custom post type slug?
- Custom taxonomy rewrite with query var returns %2F in URL
- Remove slug in URL custom post type
- Custom Permalinks with CPT and Hierarchical Taxonomies
- URL rewriting for CTP assigned entity
- Custom Permalink Structure for Custom Post Type, Custom Taxonomy, Under a page
- Custom taxonomy returns 404
- 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
- Custom URLs in post types make it impossible to view archive
- post_type_link Filter – Too Few Arguments
- Custom Post Type Category URL
- WordPress custom permalink and archive link for custom post type
- Urls in Custom Post Type work for Terms but not for its Taxonomies
- Taxonomy rewrite pagination 404
- Archive page for custom post type and custom taxonomy
- custom post archive URL is wrong
- Custom taxonomy and post type rewrite rules
- Custom Post Type and Taxonomy Rewrite Error
- Custom taxonomy terms as children of multiple custom post types
- Remove cpt slug from url and use custom taxonomy instead breaks all other cpt
- Custom Permalink For Custom Post Type – Working Fine But Broken For Pagination
- I want to rewrite the URL of a specific post with a specific custom field to easily analyze in Google Analytics
- Custom Post Type & Taxonomies – Rewrite
- How to properly set the rewrite rules for this case?
- Display CPT taxonomies as an archive page
- Change CPT permalink to use the category
- How to fix 404 on post after prepending Custom Post Type url with Custom Taxonomy Term slug
- Redirect Custom Post Type from Child Taxonomies
- Custom post type structure + permalink structure
- Custom URL for Custom Post Type & Custom Taxonomy Term
- Custom taxanomy and custom post type – pagination leads to 404
- Register post type getting error 404
- Flush rewrite rules when new cpt is registred
- What am I doing wrong with my taxonomy?
- CPT url rewriting : regular posts return 404 error
- Custom Post Type rewrite url to /category/pagetitle [duplicate]
- Remove custom post type slug but keep related category taxonomy permalink
- page not found for example.com/custom-post-name
- Custom post type with parent page? Possible?
- redirect old post type url to new structure url
- One custom post type with two different url structure base on taxonomy term
- Why is a custom post type’s URL “/?cposts=name-of-the-post” but default post’s URL is “/?p=ID”?
- Remove custom taxonomy ‘post-type’ from post URL
- Sorting custom post types by taxonomy (So close)
- Custom Post Type Base URL
- Custom Taxonomy in Permalink from post type
- Tags and Taxonomy links not working for Custom Post Types
- How can i change url structure of cpt like this?
- Menu Structure and URL structure, with Pages and Post-Type-Posts
- Is it possible to use a post name in a custom post slug?