I have a WP Multisite that contains 3 sites – sites 1, 2, 3
Site 1 and 2 are just one page but site 3 has multi pages inside.
I would like to show a navigation on the top of each site to the other sites.
I would also like to show the child pages in site 3 on every page.
I’m using this code here to create the nav for all the sites.
<div class="navbar-collapse collapse">
<?php
$the_blog_id = get_current_blog_id();
$bcount = get_blog_count();
global $wpdb;
$blogs = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM $wpdb->blogs WHERE spam = '0' AND deleted = '0' and archived = '0' and public="1"",13, 'stack overflow' ) );
echo ( $blogs->blogname );
if ( !empty( $blogs ) ) {
?>
<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
foreach ( $blogs as $blog ) {
$details = get_blog_details( $blog->blog_id );
if ( $details != false ) {
$addr = $details->siteurl;
$name = $details->blogname;
$id = $details->blog_id;
// echo $name ." is blog ". $id."https://wordpress.stackexchange.com/";
if ( !( ( $blog->blog_id == 2 ) && ( $show_main != 1 ) ) ) {
$class = ( $blog->blog_id == get_current_blog_id() ) ? ' current-site' : '';
?>
<li class="menu-item<?php echo $class; ?>" >
<a href="<?php echo $addr; ?>"><?php echo $name;?> <i class="fa fa-chevron-right pull-right chervonMobNav"></i></a>
<?php
if ( $blog->blog_id == 4 ) {
echo 'here';
//show the nav for blog 4
$pages_args = array(
'title_li' => '',
'depth' => 0
);
wp_list_pages( $pages_args );
}
?>
</li>
<?php
}
}
}
?>
</ul>
<?php
}
?>
</div><!--/.nav-collapse -->
The problem here is it only shows the pages in site 3 when I click that link and go it that site.
I want the nav to show the pages in site 3 when I’m on site 1 and site 2
So the nav in each site should look somneting like.
Site One | Site Two | Site Three
Site Three - page 1
Site Three - page 2
Site Three - page 3