You did a good job writing your own query to get all the sites/blogs, but there’s also a special WordPress function you can use: wp_get_sites()
If you want to get content from another site/blog you have to switch first with switch_to_blog()
to make sure your query will run within the right context. (And don’t forget to switch back to normal with restore_current_blog()
afterwards!)
Having that said, I updated your snippet accordingly, so you can give it a try:
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav">
<li class="portalHome">
<a href="https://wordpress.stackexchange.com/questions/163594/dashboard.html">
<i class="fa fa-home"></i>
<i class="fa fa-chevron-right pull-right chervonMobNav"></i>
</a>
</li>
<?php
$args = array(
'public' => 1 // limit to public sites
);
$sites = wp_get_sites( $args );
$current = get_current_blog_id(); // current blog id
foreach ( $sites as $site ) :
$site_meta = get_blog_details( $site['blog_id'] );
$current_class = $site['blog_id'] == $current ? ' current' : ''; // check for current site
echo '<li class="menu-item' . $current_class .'" >';
echo '<a href="' . $site_meta->siteurl . '">' . $site_meta->blogname . ' <i class="fa fa-chevron-right pull-right chervonMobNav"></i></a>';
if ( $site['blog_id'] == 4 ) : // check for special site
switch_to_blog( 4 ); // now switch to this site
$pages_args = array(
'title_li' => '',
'depth' => 0
);
echo '<ul>';
wp_list_pages( $pages_args );
echo '</ul>';
restore_current_blog(); // switch back to normal
endif;
echo '</li>';
endforeach;
?>
</ul>
</div><!--/.nav-collapse -->