• I’ve a clean new wordpress, with only divi applied to it so far.

    I had idea to have at least two types of posts, blog and article. I found online I can remove the ‘category’ entirely in permalinks, by just entering a period into the “Category base” name and a custom structure for /%category%/%postname%

    It works pretty well, I can go my site /blog to get directly to the archive blog category or /article to go the archive article category, without needing write category/blog or category/article after my main website address.

    But the problem comes to subcategories.

    If I have a category named blog and another subcategory to that named journal, then my posts will be /blog/journal/post-name-here which is what I want.

    Problem occur on the meta links for the post, if I click on journal it will direct me to /blog/jorunal, however this site cannot be found apparently! Even if I have posts in there, it doesn’t list them. Instead I found out it doesn’t use the parent category at all and is found on /journal

    How come it’s this way? I been searching online but haven’t found answer. All I find is plugins, but this is such base structure for wordpress so is there no other option I’m missing out on?

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    The reason is using a period for category base is a crude hack. It’s coincidental that it works at all. Its functioning is incomplete as you’ve seen. WP finds resources based upon requested URLs based on various rewrite rules. When we use an actual base arg like “category”, the request gets matched to a rewrite rule that can accommodate multiple subcategories. When you use a period as base, a different rewrite rule gets matched which cannot accommodate subcategories.

    A conflict is introduced where WP cannot discern if we’re requesting a subcategory or a post. With /blog/journal, WP assumes it’s a “journal” post being requested, which does not exist and we get a nothing found response.

    You have a choice. Either use a proper category base, or don’t have subcategories. There is a 3rd alternative. With a custom rewrite rule you can have a unique URL structure, but with other limitations. Such as the last URL element is always a post slug, so you cannot have category only requests. Or all URLs must always include a subcategory, no top level only category requests can work. There are numerous possibilities, but they all involve trade-offs.

Viewing 1 replies (of 1 total)

The topic ‘Subcategory permalinks doesn’t work’ is closed to new replies.