admin管理员组

文章数量:1128196

I am creating a WooCommerce store with a very big nested menu structure. Is there a way to stop my product categories from paginating?

I need them to all show in one big list so that I can use Ctrl+F to find them quickly. That "Search" next to "View All" isn't working.

Any help is appreciated.

I am creating a WooCommerce store with a very big nested menu structure. Is there a way to stop my product categories from paginating?

I need them to all show in one big list so that I can use Ctrl+F to find them quickly. That "Search" next to "View All" isn't working.

Any help is appreciated.

Share Improve this question edited May 21, 2019 at 9:52 LoicTheAztec 3,38117 silver badges24 bronze badges asked May 20, 2019 at 22:50 Charis The ProgrammerCharis The Programmer 1235 bronze badges 2
  • 1 @LoicTheAztec your code worked! Thank you very much. However the pagination is still showing but the code is doing what I needed done. – Charis The Programmer Commented May 24, 2019 at 15:48
  • Happy it wordked, as I didn't really test my code (what I mostly never do). – LoicTheAztec Commented May 24, 2019 at 15:52
Add a comment  | 

2 Answers 2

Reset to default 2

Based on "Remove Pagination in Appearance -> Menus -> Categories" answer thread for WordPress categories, you will adapt the answer code to WooCommerce Product Categories.

The taxonomy of WooCommerce Product category is product_cat.

Is also better to target admin nav menus only.

Try the following (untested):

add_filter( 'get_terms_args', 'admin_nav_menu_show_all_product_categories', 10, 2);
function admin_nav_menu_show_all_product_categories( $args, $taxonomies ) {
    global $pagenow;

    if( 'nav-menus.php' === $pagenow && reset($taxonomies) === 'product_cat' ) {
        $args['number'] = '';
    }
    return $args;
}

add_filter('terms_clauses', 'change_product_cat_terms_clauses', 10, 3 );
function change_product_cat_terms_clauses( $clauses, $taxonomies, $args ) {
    global $pagenow;

    if( 'nav-menus.php' === $pagenow && reset($taxonomies) === 'product_cat' ) {
        $clauses['limits'] = '';
    }

    return $clauses;
}

Code goes in functions.php file of your active child theme (or active theme). It could works.

Thanks LoicTheAztec, it works for me. Pagination destroys my product category hierarchy and displays in the wrong positions. But after your code snippet, pagination still displays, so Ive added this:

function admin_product_cat_terms_nopagination($hook_suffix) {
    if ( $hook_suffix == 'nav-menus.php' ) {
        echo '<style>#tabs-panel-product_cat-all .add-menu-item-pagelinks{ display:none }</style>';
    }
}
add_action('admin_enqueue_scripts', 'admin_product_cat_terms_nopagination');

本文标签: custom taxonomyRemove pagination from WooCommerce product categories on admin edit navigation menus