0

I tried to remove /category/ base from permalink structure, keeping parent category, but Wordpress gives me back 404 error page.

I'm not using any particular plugin to do that, only using . in category base and using %category%/%postname%/ as permalink structure.

If I restore /category/ base everything works fine. I have already used '/' and '.' to remove category base.

How can I solve the problem?

  • Have you seen a site that is able to do that? – Alexis Wilke Dec 29 '17 at 9:58
  • Obviously yes. I do not understand how your answer could help. – Stefano Dec 29 '17 at 10:33
0

Just enter '/' OR '.' (without quotes) as the value for Category base.

Seemed to work perfectly when I tested it. I'd be interested in hearing if anyone discovers other dangers to doing this, other than the obvious potential of collisions between posts, pages, and categories.

  • Thank you for the reply. Unfortunately / or . don't work at all'. The permalink is correct but gives me back 404 error – Stefano Dec 29 '17 at 9:10
0

Okay, I tested and can reproduce the problem on my test website. The Posts work as expected, but indeed, the sub-categories fail.

One solution, which is really not practical if you have a large number of categories, but resolves the issue, is to create pages with the same paths and use a Shortcode in those pages. The Shortcode will display the corresponding pages as a list. The one problem is it won't use the same formatting as expected by default in your theme...

So if you have a parent category named parent and a child category named child, you:

  1. create a page with the path set to /parent/
  2. create a child page with the path set to /child/ and then mark it as a child of /parent/

Note that you can't get the correct path for the child page (/parent/child/ in my example) without first creating the parent page. One good thing is that the look and feel of the list in the parent will thus have the same look and feel in the child.

In the pages, you can enter any text you'd like and then use a Shortcode such as this:

[display-posts category="second-category"]

I use the Display Posts Shortcode plugin, which is probably not the best plugin available for that job, but it has the advantage of work well. Feel free to try with others...

Now if you have hundred of categories and add/remove many of them all the time, that's going to be a nightmare. If you have a few well selected categories, you should be just fine that way. (You'll also need a little CSS to help the output formatting.)

There is a screenshot of the child page. We see that the path looks correct. This is because I setup the parent (right side of screen). I also show the Shortcode.

enter image description here

Now, what you should probably do is report that problem as a bug at WordPress.org.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.