The post_type_link
filter is responsible for modifying the permalinks that are output, but it’s not connected to resolving incoming requests for those permalinks. So you’ll need to modify your function to output the correct links, but also add a rewrite rule so WordPress knows what to do when those pages are requested.
This is all untested, but off the top of my head you could modify the classification slug to add a trailing slash:
$taxonomy_slug = $terms[0]->slug . "https://wordpress.stackexchange.com/";
then modify the no classification case to just be an empty string:
else $taxonomy_slug = '';
Then replace the classification tag and trailing slash:
return str_replace('%classification%/', $taxonomy_slug, $permalink);
Then to handle those requests without classification, add another rewrite rule on init
:
add_rewrite_rule(
'data/([^/]+)/?$',
'index.php?dr12-documentation=$matches[1]',
'top'
);
Related Posts:
- Custom Post type & Taxonomy URL structure
- Combining Multiple Taxonomies in one URL
- Dynamic taxonomy in permalink made all other posts NOT FOUND?
- Remove Taxonomy Slug when No Taxonomy is Assigned to Custom Post Type?
- Custom Permalink with Dynamic Taxonomy for Custom Post Type – Works, but breaks other permalinks
- Custom Taxonomy breaking pages permalinks
- Custom Post Type with two hierarchical Custom Taxonomies: strategy to generate best permalink structure
- Custom Post Type Advanced Slug
- Custom post type URL structure with site.com/custom_taxonomy_slug/post_name
- Remove Custom Taxonomy Slug only without removing Custom post type slug in permalinks
- Hide custom post type slug url from search engine [closed]
- Custom post types, taxonomies, and permalinks
- Permalinks: custom post type -> custom taxonomy -> post
- Mixing custom post type and taxonomy rewrite structures?
- Shouldn’t this be easy?! Custom post type/custom taxonomy permalink
- How do I append multiple taxonomies to the URL?
- WordPress Rewrite Rules for Custom Post Type and Taxonomy
- Permalink rewrite 404 conflict- WordPress Taxonomies/ CPT
- Why does a custom post type need the ”hierarchical’ args setting?
- Taxonomy archive with same slug as custom post type?
- Help with a TV series Rewrite structure
- Custom Post Type with Nested Taxonomy and Template Files
- Custom permalinks – post type – hierarchical taxonomy’s
- Remove Slug from Custom Post Type results in 404
- Page to display an archive of taxonomies
- How to create a permalink for custom taxonomies and custom post types like base-name/parent-tax/child-tax/custom-post-type-name
- How to show custom taxonomy in the permalink?
- Date-based permalinks for Custom Post Type, and custom taxonomy permalinks
- Custom permalink – append taxonomy name and term name at the end of permalink
- Permalinks for custom post-types within custom taxonomies not found
- Add hierarchical taxonomy to permalink for custom post type
- Parent & Child Taxonomy slugs in custom post permalink
- Custom Post Types and independent Categories – complex Taxonomy
- custom permalinks based on taxonomies for custom post type
- Wrong generated page_name/slug on first publish of custom post type
- Stop / prevent WordPress from updating permalinks of custom post type
- Custom taxonomy in URL showing 404
- 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
- Create a custom php page and load it at a specific slug
- Permalinks /country/city/cpt/postname/
- Seamless permalinks between Custom Taxonomy and Custom Posts
- Custom post type and custom taxonomy with the same slug using the file page taxonomy only as directory
- How to change permalink to include custom post type
- Custom post type permalink tag 404
- set permalink for CPT
- How to add current custom taxonomy slug to body class
- Template for custom post type when taxonomy is in the URL
- Permalink problems with custom post type and custom taxonomy
- Custom Post Type to replace Woocommerce products – page not found error
- Ideas on how to organize a project [closed]
- Change permalinks for custom post type based on taxonomy term
- Under What Conditions Can I name my CPT the same as my CPT Page?
- Custom post type category permalinks and archive pages
- Safe to throw 404 error in request filter?
- Multiple permalinks for a single post with multiple taxonomies
- How do I set a post slug automatically based on taxonomy?
- 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?
- Remove custom taxonamy slug with pagination
- 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
- Customise Permalink Structure For Custom Post Types
- How to create a permalink structure with custom taxonomies and custom post types
- Pagination not working (page/2 retunring 404 page)
- Custom post type post_type_link gives “page not found” on any other custom post type
- Two CPT: one is using part of the custom rewrite slug from the other
- Custom permalink rewrite rules – how do I fix this?
- 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
- Can I override the permalink/slug on creation
- Multiple archives for cpt, taxonomies, terms
- Same permalink structure for all post types?
- How to add base permalink to custom posts?
- Hierarchical taxonomy in permalink structure
- 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
- Can’t make permalink of CPT work
- Parent cpt/child custom post type URL permalink relationship
- How to make nested custom post type slugs work
- Custom Post Type Permalinks Problem
- Change Taxonomy Permalinks
- WP Query Post Type with same Taxonomy name
- Category / Custom Post Type permalink issue
- Adding rewrite rules to Custom Post-type mixed with Taxonomy
- How to have a dynamic slug and rendering the archive-{post_type}.php?
- Add /blog to the “post” post type url
- Custom Post Type with multiple Custom Taxonomies / Hide Taxonomy Slug from URL
- Is it possible to use a post name in a custom post slug?
- Taxonomy Archive URL + Template