What’s the Simplest Way to Override/Rewrite the %category% Permalink Structure Tag?


See: https://wordpress.org/support/article/using-permalinks/

By default, when someone sets their permalink structure to:


Post URLs appear like so:


ABC merely represents the first category of potentially several selected for the post, but unlikely the most appropriate.

I’ve made it so that my writers can select which category should be most prominent, which is saved as post meta for each post, and can be output with the variable $prominent_category.

I would like to automatically replace %category% with $prominent_category in the slug, without the need of registering an additional taxonomy or doing anything else that might be overkill, so that whatever the author sets as their prominent category, say Pizza, that the new structure for the post appears as so:


Are either category_rewrite_rules or post_link_category the right choice, or should I be going down a different path?

OverrideCategory 2 years 2020-12-31T04:11:04-05:00 0 Answers 2 views 0

Leave an answer