3

I have over 800 pages in WordPress which becomes a challenge trying to find a specific page to add it to the menu. View all works if you have only a few pages so the best option would be to search for the page to add it to the menu. The problem is that the search result only brings up 10 pages, I need it to return more results (say 30) so I can find the page that I am looking for, the page that I am looking for might be result number 22 but I can't find it because it is not displayed, hope this makes sense.

Just a reminder that I want to increase the search results for "Admin -> Appearance -> Menus -> Search" and not "Admin -> Pages -> Search"

Any body can help me with what code to add to the functions.php file to increase the search results?

Thank you in advance Tony

  • I dont understand.. (sorry) - do you means the regular search results displayed after you enter a search query only returns 10 results and you have "next" "previus" buttons? – Sagive SEO Mar 28 '12 at 16:01
  • Hi Sagive SEO. @Sagive SEO Thanks for getting back to me "Admin -> Appearance -> Menus -> Search" only gives 10 results by default, there isn't a next or previous button as when you do a regular search in the admin area under "Admin -> Pages -> Search" See image attached:[link] (dontremove.s3.amazonaws.com/appearance-menus-search.png ) – Tony Mar 29 '12 at 13:51
4

No need to change core files! Here is a hook (add in functions.php or simple plugin):

// filtering quick-menu-search results (this seems better than others at https://pastebin.com/raw/jRkJYAzE )
add_action( 'pre_get_posts', 'myFilter1', 10, 2 );
function myFilter1( $q ) {
    // example of $q properties: https://pastebin.com/raw/YK1uaE0M
    if(isset($_POST['action']) && $_POST['action']=="menu-quick-search" && isset($_POST['menu-settings-column-nonce'])){    
        // other parameters for more refinement: https://pastebin.com/raw/kZ7hwpyx
        if( is_a($q->query_vars['walker'], 'Walker_Nav_Menu_Checklist') ){
            $q->query_vars['posts_per_page'] =  30;
        }
    }
    return $q;
}

change 30 to whatever you want.

1

I also needed this functionality, the answer is around line 330 in wp-admin/includes/nav-menu.php

Change:

'posts_per_page' => 10,

to:

'posts_per_page' => 1000,

or whatever you'd like. Note you can also change the number of items under the other tabs in this file.

This applies to version 3.4.2 of wordpress.

  • Then you would be stuck at this WP version, because you cannot upgrade anymore without losing the changes. Not a good idea. – fuxia Nov 8 '12 at 16:59
  • Still, good enough for a temporary fix (just to get the menus established) if you're setting up nav for a site with hundreds of pages. The search functionality really doesn't work well and paginating through the 'View All' can take ages. Thanks John! – Michelle Feb 4 '13 at 23:24
0

ok... sorry - i have searched and as for now i cant find a way to hard code this option... hope someone of the many wordpress experts here would help reach a hard coded solution.

For now i would reccomend you use the built in Search capability of your browser to do a simple search for the desired name...

See Image:
enter image description here

  • Thanks for the feedback. I know what the URL is for the page but can't add it to the menu without finding it in the "Most Rent" "View All" or "Search" options in the "Admin -> Appearance -> Menus -> Search" first. – Tony Mar 29 '12 at 22:12
  • i think once on "view all" you can search using your internal broweser search using the page name and those find it easily... i think it would be just as fast and really the same as searching using wordpress.. – Sagive SEO Mar 30 '12 at 2:35
  • Thanks I tried it and it is a very us full trick I must say. On the "View All" tab WordPress will show 50 pages in a group then you need to select "<< 1 2 3 etc..." navigation to see the next group of pages. I use the browser's search function to highlight the pages that I need. – Tony Mar 30 '12 at 15:22
-1

In the newer Wordpress version 4.9.5, it is line '80' in nav-menu.php.

To change the number of Wordpress menu pages search results (Admin > Appearance > Menus > Search) from 10 results to more go to:

wp-admin > includes > nav-menus.php > line '80' > 'posts_per_page' => 10,
Change the 10 to some other number.

This assumes you have a way to actually edit nav-menu.php. Or can change the permissions if need be so that you can edit. And yes, it also assumes you will need to re-implement if there is a Wordpress upgrade. But once you have your menu configured, it may not even be necessary after that. A default of 10 search results, is downright silly in my opinion. Some sites have hundreds, even thousands of posts or pages.

  • It is bad practice to change the WordPress source directly as you will either lose changes when updating it, or be forced to avoid updating WordPress. – Nick Bedford Jun 26 '18 at 1:27
  • I understand... that's why I clearly stated: "it also assumes you will need to re-implement if there is a Wordpress upgrade". – Heres2u Sep 24 '18 at 15:29

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.