Your previous edit was a bit closer. Change the post type rewrite slug to:
cosmetics/treatments/%treatment-type%
Then change all instances of %type% to %treatment-type% in the treatment_permalink function.
Everything should then work correctly after you flush rewrites.
For future reference, the Monkeyman rewrite analyzer plugin is very helpful for debugging rewrite rules. As I mentioned, you can also dump the contents of $wp_query to see what WordPress is trying to query for in each request. You can put something like this directly in a 404 template for quick debugging of requests that you think should not be a 404:
<pre>
<?php print_r( $wp_query ); ?>
</pre>
You’ll see a list of all query vars with their values and the resultant SQL query WordPress is sending to the database.
Related 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
- Remove taxonomy slug from a custom hierarchical taxonomy permalink
- Shouldn’t this be easy?! Custom post type/custom taxonomy permalink
- Custom Post Type Permalink / Rewrite not working immediately
- Custom Post type & Taxonomy URL structure
- Combining Multiple Taxonomies in one URL
- Why does a custom post type need the ”hierarchical’ args setting?
- Templates for Custom Post Types and Custom Taxonomies
- 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
- array_pop() expects array, boolean given for $event_type_term ->slug
- Understanding Permalinks on Custom Post Types
- custom post type permalinks with category and tags
- Permalink rewrite with custom post type and custom taxonomy
- Add links to post categories and taxonomies in wysiwyg link modal?
- Custom Permalinks for Custom Post Types and Taxonomies
- Custom Post Type with Nested Taxonomy and Template Files
- Semantic URL Custom Post Type and Taxonomies permalinks
- How to rewrite custom post type URL for multiple depths instead of one specific depth
- Maintaining WP_Query Relation Among CPT, Custom Taxonomy, Permalinks- CPT UI
- Custom post type category, taxonomy and URL rewrite problem
- Define permalinks for custom post type by taxonomy in WP 3.4
- Custom Post Type: How to display all of same taxonomy?
- Remove “-2” from a Toolset Types URL with the same post name
- Remove Taxonomy Slug when No Taxonomy is Assigned to Custom Post Type?
- Include taxonomy slug in url?
- Custom permalink – append taxonomy name and term name at the end of permalink
- custom post type and custom taxonomy url conflict
- multiple url slug for single custom post type
- Add hierarchical taxonomy to permalink for custom post type
- Custom post types, taxonomies, and permalinks
- How to specify URLS for custom posts & taxonomies
- Custom post types, taxonomies, and permalinks
- Permalinks not working for custom taxonomy on custom post type
- custom permalinks based on taxonomies for custom post type
- Custom taxonomy in URL showing 404
- Custom Post Type permalink shows wrong page: homepage/index.php
- 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
- create a subcatagory for a custom post type and out put url as posttype/subcategory/item
- custom-taxonomy/post_name instead of the default post_type/post_name
- Show custom post archive when custom post not specified
- Show custom post type relationships by taxonomy
- Permalinks: custom post type -> custom taxonomy -> post
- 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)
- Custom post type and taxonomy permalinks
- Hierarchical permalinks for custom post type and taxonomy
- set permalink for CPT
- Best way to specify “article type” in URL
- Template for custom post type when taxonomy is in the URL
- Permalink problems with custom post type and custom taxonomy
- Custom Post Type Advanced Slug
- Ideas on how to organize a project [closed]
- Change permalinks for custom post type based on taxonomy term
- Custom post type category permalinks and archive pages
- Custom category URL not displaying posts
- Safe to throw 404 error in request filter?
- Multiple permalinks for a single post with multiple taxonomies
- Duplicate slug/permalink issue while adding same post name
- Is there a way to use ‘publicly_queryable’ => false only on specific taxonomy term?
- How to prefix custom post type URL with custom post taxonomy term?
- How do you create pillar content pages?
- Custom post type single page returning 404 error when sharing archive url with custom taxonomy
- Changing permalink of default Post with custom post
- Custom Taxonomy Archive generates 404
- Custom post type single with custom URL structure
- Pretty Permalinks with CTP and Taxonomies / Hierarchical
- Customise Permalink Structure For Custom Post Types
- How to create a permalink structure with custom taxonomies and custom post types
- Issue with Custom Post Types and Permalinks
- Pagination not working (page/2 retunring 404 page)
- Custom permalink with custom taxonomies for custom post type
- Template hierarchy changes when custom post-type permalink leverages custom taxonomy
- Associate custom CPT with another CPT’s taxonomy and rewrite permalinks
- Change the url of a custom post type to include taxonomy
- Post Custom & Taxonomy 404 error
- How to have permalink structure based on taxonomy terms
- Multiple archives for cpt, taxonomies, terms
- Multiple post types or single post type with category taxonomy?
- How to add base permalink to custom posts?
- How can I add a “fake” parent into the permalink?
- Permalinks when using Custom Post Type with static page for archive
- How to change permalinks to taxonomy and post type’s posts
- taxonomy term names in custom post type permalink structure
- Adding 2 CPT with multiple custom taxonomies to permalinks
- Parent cpt/child custom post type URL permalink relationship
- Custom Post Type Permalinks Problem
- Change Taxonomy Permalinks
- Permalink for Custom Post Types
- Remove slug from Custom Category Permalink + dual-category permalinks
- How to have a dynamic slug and rendering the archive-{post_type}.php?
- Add /blog to the “post” post type url
- Different CPT permalink base on taxonomy
- Hide custom post type slug url from search engine [closed]
- Is it possible for post and custom post type to share a category base slug?
- How does WordPress manage to differentiate between post and page URLs without a distinct base, and how can I replicate this functionality?
- How to correctly edit permalink structures for both default and custom posts/taxonomies?