Remove taxonomy slug when not assigning taxonomy with custom post types

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'
);

Leave a Comment

error code: 523