• Resolved jshrek

    (@jshrek)


    I have a Custom Structure setup for posts in Settings > Permalinks as /%category%/%post_id%-%postname%

    This works great for most of my posts, but there is one category that I want to remove the post_id from so it looks like this /%category%/%postname%

    So if the category is CAT and the post-id is 123, then the permalink correctly looks like this:
    mydomain.com/cat/123-my-great-cat-post

    But if the category is DOG then I do not want the post-id, so it should look like this:
    mydomain.com/dog/my-great-dog-post

    I understand how to use actions and filters in my functions.php and I think I want to use either generate_rewrite_rules or post_rewrite_rules or add_rewrite_rule and add a new rule to the TOP.

    I am honestly confused as how to write the rule though as regex is complicated and I do not understand it.

    Any help appreciated.
    Thanks

    rewrite,rule,rules,generate,add,post,api,regex,generate rewrite rules,add rewrite rule

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Add rewrite rule to permalink structure’ is closed to new replies.