Opened 5 years ago
Closed 5 years ago
#47639 closed defect (bug) (duplicate)
WordPress unable to show (WooCommerce) categories in their order (and how to fix it)
Reported by: | Jorix | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | 5.2.2 |
Component: | Menus | Keywords: | needs-patch |
Focuses: | ui, administration | Cc: |
Description
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
---
- Create an extensive list of at least more than 50 categories
- WordPress CMS > Appearance > Menus
- Try to make a menu that reflects (or partly reflects) your extensive categories structure
To temporary fix (WP 5.2.2)
---
- go to wp-admin\includes\nav-menu.php
- line 659 (under function wp_nav_menu_item_taxonomy_meta_box)
- 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.
<?php /* 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; }
Hi @Jorix, welcome to WordPress Trac!
Thanks for the report, we're already tracking this issue in #18282 and #19837.