3

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.

enter image description here

2

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;
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.