• How can i increase the search results inside the “search field” on the WP-Admin -> Design->Menu Editor?

    I have 17.000 Categories. But if i try to search, it shows only 10 results for categories. I tried to increase the limit_posts_per_page on the wp-nav.php without any effect.

    The Plugin WP Admin Category Search does only works inside Posts and Sites and not on the Menu Editor of Design.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter berlinux

    (@berlinux)

    I also tried this code:

    add_action( 'pre_get_posts', 'myFilter1', 10, 2 );
    function myFilter1( $q ) {
       
        if(isset($_POST['action']) && $_POST['action']=="menu-quick-search" && isset($_POST['menu-settings-column-nonce'])){    
           
            if( is_a($q->query_vars['walker'], 'Walker_Nav_Menu_Checklist') ){
                $q->query_vars['posts_per_page'] =  15000;
            }
        }
        return $q;
    }

    without any effect.

    Moderator bcworkz

    (@bcworkz)

    I’m unsure what Design>Menu Editor is, it sounds like a theme or plugin add-on. The following may not apply, it applies to object searches from nav-menus.php, the default menu editor. Searches are via Ajax requests. You could remove the default Ajax callback and replace it with your own customized version. The action hook is “wp_ajax_menu_quick_search”. The callback is of the same name:
    https://developer.www.ads-software.com/reference/functions/wp_ajax_menu_quick_search/

    The function uses get_terms() for category searches, you could instead use the “pre_get_terms” action to alter the “number” query var to a more desirable quantity. The trick here would be to differentiate a menu item quick search query from all other term queries. Perhaps it could be distinguished by the query vars used. Or use the above Ajax hook to add your “pre_get_terms” callback just before _wp_ajax_menu_quick_search() is called.

    Thread Starter berlinux

    (@berlinux)

    I mean:

    Themes > Menu > Add Menu > Add Category and there the search field for categories.

    Could you please modify it thus it works?

    Moderator bcworkz

    (@bcworkz)

    I think you mean Appearance > Menus?? By default there’s no menuing under Themes. Anyway, $_POST['action']=="menu-quick-search" is correct. The passed nonce should be verified. I’m unsure which value is used to seed the nonce creation. It could be “menu-quick-search”, but it’s just a guess. It’d be best to locate the core code that generates it to confirm.

    To further narrow down the correct query, verify that the $_POST['type'] == 'quick-search-taxonomy-category'. If those check out, then do
    $q->query_vars['number'] = 50;
    Limiting number to 15000 is absurd. Use a reasonable value for terms that will fit in a dropdown box.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Increase Search Results for WP-Admin Design – Menu Editor’ is closed to new replies.