Viewing 3 replies - 1 through 3 (of 3 total)
  • The POST category base (default “category”) is just that: a base or static separator added to category archive URLs. It’s not a destination or an archive page, so it should return 404.

    Why is this necessary? Say you have a post with the slug development and a category with the same slug development, how can WordPress distinguish between the two? By adding this category base, the category permalink becomes /category/development/ while the page’s permalink becomes /development/.

    Note that this is a special case, and totally different from a CPT’s archive, which, if the CPT supports archives and has content published, should list the CPT’s posts and not return 404.

    If you can provide your actual URL, I could check and give you more specific feedback.

    Good luck!

    Thread Starter wrip

    (@wrip)

    My expectation is that /news/category/ by default should list all the categories or at least display something rather than returning “page not found”. It could just list the categories such as “development”, “design”, etc. Having a slug in a URL that returns “page not found” is just doesn’t seem right to me.

    Anyway, I’ve figured out a solution for this. I still don’t fully understand why this was not done by default.

    Keeping with the same structure as the News in the example above, this is what I tested:

    Under Dashboard > Pages:

    I created a new Category page.

    News (Posts Page) (/news/)
    — Category (/news/category) – This tied up with page.php template (or page-category.php)

    Development (/development) – This tied up with page.php template

    Under Dashboard > Categories:

    Development (/news/category/development/) – This tied up with archive.php template

    Under Dashboard > Posts:

    Development (/news/development/) – This tied up with single.php template

    This worked for me and had no conflict with anything. I also tried something similar with my CPTs. They are all working fine.

    I’m glad you found a solution that works for you.

    Just a couple of inline comments below (feel free to skip what follows) ??

    My expectation is that /news/category/ by default should list all the categories or at least display something rather than returning “page not found”

    No, that’s now how WordPress works.

    And please don’t shoot this messenger: I’m merely telling you what IS. I’m not arguing that this is “right” or “wrong” ??

    It could just list the categories such as “development”, “design”, etc. Having a slug in a URL that returns “page not found” is just doesn’t seem right to me.

    That may be your desire: nothing wrong with desiring that. But note that what WordPress is doing here is nothing uncommon.

    Eg: https://www.google.com/search/howsearchworks/ has a page

    But: https://www.google.com/search/ returns 404 Not Found (at least from my end)

    There’s simply no technical requirement that all the paths in a given URL should return some content. Sometimes it may even be desirable to completely block users (403 Forbidden or something else) from accessing such a path.

    This worked for me and had no conflict with anything. I also tried something similar with my CPTs. They are all working fine.

    The “conflict” I mentioned was concerned with when people choose to remove the “category” prefix from the category archive URLs.

    If you were to do this, then, in your case, there would be no /news/category/ at all, and the “Development” category archive page /news/category/development/ would become just /news/development/ (ie the prefix /category/ is removed).

    So you’d have a CATEGORY at /news/development/

    And a PAGE at the same /news/development/

    … which obviously would be a problem.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘‘Category’ page is showing 404’ is closed to new replies.