Support » Fixing WordPress » Customising permalink structure based on categories

  • TJ


    Hi all.

    I would like to set custom permalinks depending on categories. More specifically, if a category is ‘a‘ or ‘b‘, I want to display root/x/postname, and if a category is ‘c‘ or ‘d‘ I want to display root/y/postname. The a, b, c & d category names should not appear; instead I want a new word – ‘x’ or ‘y’. I also really want to avoid the word ‘category’ in the URL, i.e. the standard root/category/categoryname/postname format (though I think the installed SEO Ultimate plugin can fix this bit).

    Here’s some context: I’m running a company website for a recruitment agency, with two general types of posts – jobs and blog articles. All are currently entered as posts, then categorised depending on their audience (for articles) or type (for jobs). There are two categories for articles (employer posts & candidate posts) and two for jobs (permanent & contract) – four post categories in total.

    So if in either of the job categories, I want the URL to be root/jobs/postname. If in either of the article categories, root/articles/postname.

    I haven’t managed to achieve this with any plugins (all I’ve found that could have done it are buggy/outdated/unsupported). I’m assuming it must be possible with some category structure tweaking, .htaccess or other modifications?

    The other issue is (if this can be done) redirects from the existing permalinks to the new format…

    Any help is appreciated – thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • You cannot map two categories to the same slug, wordpress needs to be able to resolve the complete url slug to a unique post, and it obviously cannot do that if you have mapped a and b onto x in the URL slug.



    Thanks for your thoughts Max.

    Won’t the unique post name be sufficient as a unique identifier? It handles root/postname just fine, so I would’ve assumed that introducing another step in the path (root/x/postname) wouldn’t negatively affect the ‘uniqueness’ of each post URL when the post name remains?

    Potential paths I’m thinking of for a solution are creating parent categories (jobs and articles) to contain the existing categories then finding a way to remove subcategories from the slug, or some sort of htaccess wizardry…

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Customising permalink structure based on categories’ is closed to new replies.