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

Question

By default, when someone sets their permalink structure to:

/%category%/%postname%/

Post URLs appear like so:

https://example.com/**abc**/some-cool-post/

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:

https://example.com/**pizza**/some-cool-post/

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

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