• I am using categories and sub-categories to organize my content and use a %category%%post-name% permalink structure. This means that a typical url for a post in a sub-category is: site.com/category/category1/subcategory1/postname . Since my url’s are longer then I would like with this type of url structure, I removed the /category/ category base slug (not the %category% from the permalink url) from the URL via the permalink settings page to get a typical subcategory url of site.com/category1/subcategory1/postname/ (notice the /category/ immediately after site.com/ is no longer present as is the case with any category when /catgeory base is used). This has created the following issue: my categories utilize my category.php template, but my sub-categories do not, they use the index.php template….. this means that sub-categories are not excerpts as they would be if they used my category template, among other changes that I have implemented in my category template……. this issue goes away if I simply add back the /category/ category base to my url structure, but this means my already long url’s get even longer…. example: https://www.site.com/category/category1/subcategory1/nameofppost/ as opposed to https://www.site.com/category1/subcategory1/nameofppost/

    Any feedback appreciated!

Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter Trace

    (@diesel12)

    Sorry if I wasn’t clear, any feedback appreciated on how I can enable to have my sub-categories recognize the category.php template when I disable the /category/ category base slug… thanks!

    Do NOT use just /%postname%/ for your permalinks, you’ll only have problems. If a category slug is making your urls too long, shorten the Category Slug in Dashboard -> Manage -> Categories.

    Thread Starter Trace

    (@diesel12)

    To clarify: I use %category%/%postname& for my default permalink structure. I was referring to removing the %category% category base slug as shown at bottom of permalink options page (the default /category/ that is present in url every time you show a category) so a default url is : https://www.site.com/category1/postname/ as opposed to the default of https://www.site.com/category/category1/postname with the /category/ base slug

    hope this helps…

    Thread Starter Trace

    (@diesel12)

    Hmmm…. if I remove the category base by editing rewrite.php in wp-includes by removing category/ (as opposed to permalinks options page where you would put /. in category base to remove category base altogether) my sub categories do utilize the category.php template correctly, but the single page permalinks do not work……. so if you click on a post title to read the article and or comments….. you get a 404 …..

    If you leave Category base blank, it defaults to category, so how are you removing it? I would strongly recommend that you do not try to do this.

    Thread Starter Trace

    (@diesel12)

    I screwed this up in previous references, disregard postname in any above url references….I am referring to category and subcategory url’s and accidentally included /postname when I shouldn’t have…

    Thread Starter Trace

    (@diesel12)

    I’m removing the category base though the permalinks options page which give you the ability to change the category and tag bases at the bottom of the page…. if you use /. as your category base it removes the /category/ base or you can change the base to whatever word you choose….

    Thread Starter Trace

    (@diesel12)

    The goal isn’t to create more trouble then its worth, which is probably the end result here… so if the category base must stay…then stay it will…. ??

    /. is not the right way to go about this, there are plugins which can remove the category base, but they require you to have a static feature in your permalink slugs… like prefix-%postname%, or %postname%.html for instance, so that the system can tell the difference between posts and categories.

    I will warn you though, I’ve experimented with %category%/%postname% quite heavily, and I can tell you that any pages listing multiple posts will be *MUCH* higher in queries, because each time the permalink is called, wordpress will have to query the database to trickle-down the parent/child relationship between categories in order to generate the permalink.

    this can really overload your site if you’re not careful.

    ultimately? not worth it. You can use a really short category base to get around most issues, and if you don’t like date based permalinks, then set your structure to /articles/%postname% – which allows you to make an /articles/ page to lay out all your categories in a sitemap format.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Sub-Category templates not working when no /category/ base slug used’ is closed to new replies.