Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#47639 closed defect (bug) (duplicate)

WordPress unable to show (WooCommerce) categories in their order (and how to fix it)

Reported by: jorix's profile Jorix Owned by:
Milestone: Priority: normal
Severity: normal Version: 5.2.2
Component: Menus Keywords: needs-patch
Focuses: ui, administration Cc:


Though my problem was with WooCommerce productcategories, I'm almost sure it will also apply to post categories if their total exceeds quite the $per_page pagination offset.

The problem
I noticed that WordPress 5.2.2 doesn't present WooCommerce categories in their set order and makes it difficult if not impossible to work with them when building nav menus because of the pagination not respecting the order and existing categories appear to be missing when using the search.

Since both by using the pagination and search functionality, didn't allow me to find and select a category I know that exists, I report it as a bug.

To replicate

  1. Create an extensive list of at least more than 50 categories
  2. WordPress CMS > Appearance > Menus
  3. Try to make a menu that reflects (or partly reflects) your extensive categories structure

To temporary fix (WP 5.2.2)

  1. go to wp-admin\includes\nav-menu.php
  2. line 659 (under function wp_nav_menu_item_taxonomy_meta_box)
  3. set the $per_page to 1000 instead of 50

The fix (see attachment)
I found a fix on stackexchange and would like to give credit to the author but for the love of WordPress I cannot find this webpage again.

/* FIX : to show categories in the correct order */
add_filter( 'get_terms_args', 'checklist_args', 10, 2 );
function checklist_args( $args, $taxonomies ) {
        $menu_taxonomies = array('product_cat', 'page', 'category','post');
        if(in_array($taxonomies[0], $menu_taxonomies))
                $args['number'] = 1000;
        return $args;

Attachments (1)

Screenshot 2019-07-02 at 16.37.53.png (97.0 KB) - added by Jorix 4 years ago.

Download all attachments as: .zip

Change History (2)

#1 @SergeyBiryukov
4 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to duplicate
  • Status changed from new to closed

Hi @Jorix, welcome to WordPress Trac!

Thanks for the report, we're already tracking this issue in #18282 and #19837.

Note: See TracTickets for help on using tickets.