[wp-trac] [WordPress Trac] #41351: Searching for a category returns nothing if category is empty

WordPress Trac noreply at wordpress.org
Mon Jul 17 21:53:57 UTC 2017


#41351: Searching for a category returns nothing if category is empty
----------------------------+-----------------------------
 Reporter:  jackjohansson   |      Owner:
     Type:  defect (bug)    |     Status:  new
 Priority:  normal          |  Milestone:  Awaiting Review
Component:  Menus           |    Version:  4.8
 Severity:  normal          |   Keywords:
  Focuses:  administration  |
----------------------------+-----------------------------
 Hi,

 In the navigation menu creation page, when you are trying to add a
 category to the menu, if the category is empty, it won't show up in the
 search results. However, if the category itself is empty but has a child
 that is not empty, it will still be shown.

 I have a blog with over 500 categories, and I'm trying to add some of them
 to the menu but they have no posts yet. Navigating through category list
 is going to take time, and is also frustrating.

 Now I've tracked down the issue to `/wp-admin/includes/nav-menu.php`, (
 starting at line 588 ) but can't find a filter or hook to do so.

 This line (109) seems to be responsible for doing the search:

 {{{
 $terms = get_terms( $matches[2], array(
     'name__like' => $query,
     'number' => 10,
 ));
 }}}


 According to the documentations, this function accepts an argument for
 showing empty terms 'hide_empty' => false, but I can't see such option in
 this part of core's code. I've added this option to the core (temporarily)
 to see if it solves the issue, and it does.

 The other `get_term()` functions withing this template file mostly use
 `'hide_empty' => false` so I'm not sure either this one was overlooked or
 not, I tagged this as a bug though.

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


More information about the wp-trac mailing list