Do you have a plugin to list all sites in a network on front end.

I am looking for a plugin that mimics what FrameMarket does, where it desplays a dropdown list of all sites in the Network. i cannot find a plugin for this, would you be able to tell me which bit of code operates this so that i could create the same function in my current theme

Thanks

  • Adam O'Connor
    • WPMU DEV Initiate

    Okay, so i have managed to get a drop down list of all sites. however when i was using gridMarket, it hid my template store that i created using one of your tutorials, however this now shows it.

    can you tell me how to hide a multisite template blog from this list.

    Thanks

  • Adam O'Connor
    • WPMU DEV Initiate

    Hi there,

    thanks for your reply.

    as suggested i have granted access.

    the plugin is called “Dropdown multisite selector” however using this means that it has to be customised for every new site that joins.

    all i really want is to have it set globally in my header, just like it is in GridMarket. any pointers i will appreciate it

    Thanks

  • Rupok
    • Ex Staff

    Hi Adam

    I hope you had a wonderful day and Merry Christmas.

    You can use the following PHP code for showing a dropdown list of all your subsites in your multisite network. Just paste the code in your theme’s header.php file where you want to show the dropdown. This code will show the blog ID for each site in drop-down selector.

    <?php
    $blog_list = get_blog_list( 0, 'all' );
    echo '<select>';
    foreach ($blog_list AS $blog) {
    echo '<option value="'.$blog['domain'].$blog['path'].'">'.$blog['blog_id'].'</option>';
    }
    echo '</select>';
    ?>

    Have a nice day. Cheers!

    Rupok

  • Adam O'Connor
    • WPMU DEV Initiate

    Hi, Thanks for the above info, however i was hoping to display the name of the blog rather than the blog ID, i have attmepeted to change the code for this purpose but with no success. this is displayed on the home page and would ideally want to exclude the blog with id of 2 from the list if this is possible.

    Thansk

  • Sajid
    • DEV MAN’s Sidekick

    Hi @Adam O’Connor,

    Hope you are doing good today :slight_smile:

    To display the blog name I have modified the code provided by Rupok that you can use by replacing the existing one. I have not tested it but it should work.

    <?php
    $args = array(
    'network_id' => $wpdb->siteid,
    'public' => null,
    'archived' => null,
    'mature' => null,
    'spam' => null,
    'deleted' => null,
    'limit' => 100,
    'offset' => 0,
    );

    $blog_list = wp_get_sites( $args );
    if($blog_list){
    echo '<select>';
    foreach ($blog_list as $blog) {

    $blog_details = get_blog_details($blog['blog_id']);

    echo '<option value="'.$blog['domain'].$blog['path'].'">'.$blog_details->blogname.'</option>';
    }
    echo '</select>';
    }
    ?>

    Hope that helps! If you still need assistance, please don’t hesitate to ask.

    Take care and have a nice day :slight_smile:

    Kind Regards,

    Sajid J