1

I've got my permalinks for a Custom Post Type set to /%custom_taxonomy%/%postname%/ using the Custom Post Type Permalink Plugin to set the custom rules for this CPT.

What this gives me is site.com/cpt/term/sub-term/postname. Yes the post is in the sub-term.

What I want is site.com/cpt/term/postname, so eliminate the sub-term from the permalink.

Looking at this question Remove child category from URL and then the code https://core.trac.wordpress.org/browser/tags/3.9.1/src/wp-includes/link-template.php#L169 you can see that the CPT's don't get to the same filter. CPT's use get_post_permalink here: https://core.trac.wordpress.org/browser/tags/3.9.1/src/wp-includes/link-template.php#L244

That only leaves me with the post_type_link filter.

How would I achieve site.com/cpt/term/postname?

1 Answer 1

1

Here is what I ended up with. Needs some clean up on my end still but it works.

https://gist.github.com/curtismchale/fa8d0570ce2c9b14880f31766c560872

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.