• Resolved AdrianB

    (@adrianb)


    Setting the limit for wp_get_sites()

    No matter how much I cleared the cache I could not get Multisite Admin Bar Switcher to show all my sites. The reason was that MABS uses wp_get_sites() with the default arguments and one of those are a limit of how many sites wp_get_sites() returns. The default is 100 sites and I have over 200 sites.

    By adding the limit argument I was able to make MABS show all my sites, like this:

    $args = array( 'limit' => 250 ); // Up the limit!
    $blog_list = wp_get_sites( $args );

    So here’s a suggestion: Add a setting for how many sites MABS should fetch.

    (Now, another issue is that the menu extends below my current screen, but that would require some kind of scrollable menu, I guess. At least I have the search field to help me.)

    https://wordpress.org/plugins/multisite-admin-bar-switcher/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author flynsarmy

    (@flynsarmy)

    If you can, send a PR here https://github.com/Flynsarmy/wp-multisite-admin-bar-switcher and I’ll merge. Remember to update the plugin version in readme.txt and the top of multisite-admin-bar-switcher.php.

    Hi

    Would someone tell me which file I could add Adrians code to so that I can get the plugin to work like Adrian is talking about?

    Is it the “mabs_admin_bar” or the “multisite-admin-bar-switcher” or is there another file that I need to edit?

    Also would someone tell me where I would need to paste the code at within the file?

    Thanks

    Mathiew Burkett
    http://www.iguy007.com

    Mathiew @iguy007, you need to make the change in “multisite-admin-bar-switcher”, but wp_get_list() has now been deprecated and replaced with get_sites() – also limit has been replaced with number.

    In multisite-admin-bar-switcher, look for the following code (around line 424).

    $blog_list = get_sites();
    $unsorted_list = array();

    And replace with this (change 250 as required)

    $args = array( 'number' => 250 ); // Up the limit!
    $blog_list = get_sites( $args );
    $unsorted_list = array();

    Cheers,
    David

    • This reply was modified 6 years, 11 months ago by davinian.
    • This reply was modified 6 years, 11 months ago by davinian.
    Plugin Author flynsarmy

    (@flynsarmy)

    Thanks David. Updated and released v1.2.6.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Setting the limit for wp_get_sites()’ is closed to new replies.