0

I have created all of my Woocommerce product categories absolutely no problem there.

Now I want to build my shop menu using the categories. The problem is, I have multiple categories with the same name but have different parents.

product categories

As you can see from the image above I have no idea which categories "Carbon" or "Aluminum" belongs to although the structure has been setup correctly as you can see below...

category structure

I have searched for plugins that might help me build the menu but found nothing.

| improve this question | | | | |
1

By default it looks like these categories are indented in the "View All" tab:

enter image description here

So you shouldn't need an additional plugin to do this. My test site only has 38 categories, but it should still indent them.

That said, if you're repeating "Aluminum", "Carbon", "Steel", etc. then you might be best off having that as a separate custom taxonomy. The WordPress Codex has some details on how you could build that out.

There are easier ways of making taxonomies though. This site has you fill out some fields and then returns PHP you'd want to include in your theme's functions.php file: https://generatewp.com/taxonomy/

Alternatively, plugins like Toolset Types have a UI to make that easier.

| improve this answer | | | | |
1

If there is a long list of categories, pagination breaks the hierarchy causing the issue OP is having.

This is a very long-standing issue. A plugin has been posted there, that disables pagination, so hierarchy is kept intact. Reported to work well up to 2500 categories & subcategories (after that it's probably a server timeout issue).

Or you can use this work-around solution (from the same discussion) in your functions.php, that also disables pagination in menu meta boxes:

<?php
add_filter( 'nav_menu_meta_box_object', 'disable_pagination_in_menu_meta_box', 9 );

function disable_pagination_in_menu_meta_box($obj) {
    $obj->_default_query = array(
      'posts_per_page' => -1
    );
    return $obj;
  }
?>
| improve this answer | | | | |
0

The answers above did not work for me.

In case anyone is looking for another solution, which did work for me, I used the following plugin/code as written by Sergey Biryukov, a core committer:

https://core.trac.wordpress.org/attachment/ticket/18282/preserve-page-and-taxonomy-hierarchy.php

| improve this answer | | | | |

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