最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

wp admin - Remove Pagination in Appearance -> Menus -> Categories

programmeradmin4浏览0评论

is there a way to remove the Pagination in the Wordpress Menu Editor?

I have something like 200 categories in my blog and customising menus seems to be tricky when you have to click through it to find the desired category.

I know there's a plugin that "removes" the pagination for PAGES but I could not find anything to remove the pagination for the CATEGORIES.

is there a way to remove the Pagination in the Wordpress Menu Editor?

I have something like 200 categories in my blog and customising menus seems to be tricky when you have to click through it to find the desired category.

I know there's a plugin that "removes" the pagination for PAGES but I could not find anything to remove the pagination for the CATEGORIES.

Share Improve this question asked Mar 28, 2018 at 10:38 mad2kxmad2kx 1722 silver badges14 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 5

As per Stackoverflow Stackoverflow

Ok after reading through the source code I found that the number of categories returned in the edit menu section is hardcoded to 50 on line 613 of \wp-admin\includes\nav-menu.php

// Paginate browsing for large numbers of objects.
    $per_page = 50;
    $pagenum = isset( $_REQUEST[$taxonomy_name . '-tab'] ) && isset( $_REQUEST['paged'] ) ? absint( $_REQUEST['paged'] ) : 1;
    $offset = 0 < $pagenum ? $per_page * ( $pagenum - 1 ) : 0;

In order to override the default of 50 per page you can set the number to '' to instruct the query to return all categories. Add the following code to your functions.php file.

add_filter( 'get_terms_args', 'show_all_categories_admin_nav_menu', 10, 2);

    function show_all_categories_admin_nav_menu( $args, $taxonomies ) {
        if( reset($taxonomies) === 'category' ) {
            $args['number'] = '';
        }

        return $args;
    }

If you set the number to blank it still shows the pagination even though it's showing all the categories.

There's also a filter called terms_clauses that exists in which you can remove the SQL LIMIT clause from the query but this didn't seem to have any affect on the query.

add_filter('terms_clauses', 'modify_terms_clauses', 10, 3);

function modify_terms_clauses( $clauses, $taxonomies, $args ) {
    if( reset($taxonomies) === 'category' ) {
        $clauses['limits'] = '';
    }

    return $clauses;
}
发布评论

评论列表(0)

  1. 暂无评论