0

Is there a way to limit the standard post categories to only allow one level of subcategories?

For example, allow the following:

Fruit 
> Apple

Veg
> Lettuce  

But from here, do not allow "Apple" or "Lettuce" to be a parent.

Is this possible and how can I do it?

Edit: The categories will be the primary method of navigation and I want to stop clients from adding endless levels of sub-categories and overcomplicating the navigation. I know I could just tell them, but I think we all know what clients are like. 1 level of sub-category is useful in this case, 10 is a mess.

5
  • Why? What is your aim - perhaps explain how you tried to achieve this also, ir order to get some relevant responses.
    – Q Studio
    Nov 13, 2020 at 16:14
  • I have edited the question to clarify my reasons.
    – Mr DC
    Nov 13, 2020 at 16:39
  • Noting that nothing prevents this in the database, so multiple UI based solutions will be needed, e.g. preventing it in the block editor UI, preventing it in the term management page when added, preventing it in the term edit screen, etc. Doing it via hooks might work but would lead to broken UIs. Suffice to say it is going to be a significant amount of work to do this, and require someone with advanced PHP CSS and React skills to accomplish thoroughly
    – Tom J Nowell
    Nov 13, 2020 at 17:23
  • Of course you could prevent your navigation from displaying a 3rd level and tell your client it isn't currently supported, and that making 3rd level items visible would require billable design work
    – Tom J Nowell
    Nov 13, 2020 at 17:26
  • Thanks @TomJNowell - this is pretty much what I'm looking for. I was hoping there was a way to restrict it without extensive modification - Clearly there is not.
    – Mr DC
    Nov 16, 2020 at 9:57

1 Answer 1

0

I would suggest you hand-build the navigation menu using the selected taxonomy terms, not using a script to automatically add them, which is where you would have problems with new terms being added.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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