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]
- Permalink for a custom post type isn’t working and I don’t know why
- 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 have the same url structure for both a CPT and a Taxonomy?
- How to create custom url structure based on custom post type rewrite slug, taxonomy and category slug?
- 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
- How can I make the slug of the taxonomy also the slug of the custom post
- Assign same parrent Page to pages AND custom post types
- Can’t remove front from permalinks for custom taxonomy category page
- Allow duplicate slugs for custom post type with taxonomies
- Removing custom post type slug from URL
- Nested Custom Post Type or Custom Post Type Parents?
- Customize Custom Post Type URL
- 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
- Custom Permalinks with CPT and Hierarchical Taxonomies
- How to have this permalink structure: post_type/postname/custom_inner_page
- Custom Permalink Structure for Custom Post Type, Custom Taxonomy, Under a page
- Custom taxonomy returns 404
- Including taxonomy term before post type breaks top level pages
- Permalinks: custom post type -> custom taxonomy -> post
- CPT’s with landing page instead of archive – Url Rewrite?
- How to change permalink to include custom post type
- Custom post type, permalinks, taxonomies and blog posts
- 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)
- permalink /category/post-name with custom post type and taxonomy
- Custom post type and taxonomy permalinks
- Hierarchical permalinks for custom post type and taxonomy
- set permalink for CPT
- Custom Post Type – Duplicate Page Slugs
- Custom permalink with child taxonomy terms
- Custom post type Permalinks with hierarchical Taxonomies
- Remove permalink for custom post type
- How to solve this custom post type goes to 404 page?
- Best way to specify “article type” in URL
- Template files for Custom Post Type and Taxonomy
- How do you create %post_type%/%postname%/ permalink structure?
- Rename a slug label
- Different slug taxonomy for two different CPT
- Can’t use pagination with custom taxonomy
- How to add current custom taxonomy slug to body class
- Using page slug in wp_query
- Listing all slugs?
- Template for custom post type when taxonomy is in the URL
- Permalink problems with custom post type and custom taxonomy
- How to filter a custom post type by custom taxonomy without 404
- How to get all posts related to particular category name on button click?
- Changing CPT slug and taxonomy already registered in parent theme
- Custom Post Type to replace Woocommerce products – page not found error
- WordPress custom permalink and archive link for custom post type
- Ideas on how to organize a project [closed]
- Enabling permalinks disables custom page template
- Need to return a string as permalink insted of str_replace
- Change permalinks for custom post type based on taxonomy term
- Under What Conditions Can I name my CPT the same as my CPT Page?
- Using page title as a link to term archive
- Custom post type category permalinks and archive pages
- Is it possible to have hierarchical taxonomy and hierarchical custom post types in one permalink?
- 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
- How do I set a post slug automatically based on taxonomy?
- Custom post type and multi taxonomies + customize url
- Custom Permalink For Custom Post Type – Working Fine But Broken For Pagination
- Set priority to permalinks
- Use custom post type taxonomy between cpt slug and name
- Is there a way to use ‘publicly_queryable’ => false only on specific taxonomy term?
- Error 404 change permalink term custom term taxonomy
- How to prefix custom post type URL with custom post taxonomy term?
- How do you create pillar content pages?
- Changing CPT permalink
- Remove custom taxonamy slug with pagination
- How can I write slugs / permalinks as: custom post type -> custom taxonomy and custom post type -> custom taxonomy (one CPT and many taxo)?
- 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
- Permalinks: custom post type -> custom taxonomy -> custom sub taxonomy -> post
- Pretty Permalinks with CTP and Taxonomies / Hierarchical
- Customise Permalink Structure For Custom Post Types
- How to change URL structure for custom post type in wordpress? Custom taxonomy + custom Post name [duplicate]
- Change permalink incrementor into pseudo-subdirectory