The MU forums have moved to WordPress.org

navigate to all blogs from within any blog (2 posts)

  1. w2ttsy
    Member
    Posted 14 years ago #

    I have a MU setup with multiple blogs and a subdomain for each of them

    bloga.example.com
    blogb.example.com
    blogc.example.com
    etc

    now i have the following code drawing out a nav successfully on the top level page (example.com) but when i go to the sub domain all i get out of my loop is "uncategorized".

    <?php
    $blogs = get_blog_list( 0, 'all' );
     foreach( $blogs as $details ) {
    		?><li class="cat_item"><a href="http://<?php echo $details[ 'domain' ] . $details[ 'path' ] ?>"><?php echo get_blog_option( $details[ 'blog_id' ], 'blogname' ) ?></a></li><?php
    	}
    
    	?>

    what am i missing for the subdomains to draw out a full nav that shows all other blogs?

    i've seen a few plugins that allow viewing this nav from the top level site, but not when drilling down.

  2. mercime
    Member
    Posted 14 years ago #

    In the sub-blog theme, place the call to blog 1 (main site) switch_to_blog(1) to get its navigation and after the place the restore_current_blog function to get back to your current blog

    <?php switch_to_blog(1); ?>
    //get what you need from the main site like main page nav
    <?php wp_list_pages('title_li='); ?>
    //restore back to current blog
    <?php restore_current_blog(); ?>

About this Topic