[wp-trac] [WordPress Trac] #47639: WordPress unable to show (WooCommerce) categories in their order (and how to fix it)

WordPress Trac noreply at wordpress.org
Tue Jul 2 14:45:20 UTC 2019


#47639: WordPress unable to show (WooCommerce) categories in their order (and how
to fix it)
--------------------------------+-----------------------------
 Reporter:  Jorix               |      Owner:  (none)
     Type:  defect (bug)        |     Status:  new
 Priority:  normal              |  Milestone:  Awaiting Review
Component:  Menus               |    Version:  5.2.2
 Severity:  normal              |   Keywords:  needs-patch
  Focuses:  ui, administration  |
--------------------------------+-----------------------------
 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
 3. WordPress CMS > Appearance > Menus
 2. 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.

 {{{#!php
 <?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;
 }
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/47639>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list