• I have a WordPress multisite that contains 3 sites – site-1, site-2 and site-3.

    site-1 and site-2 are sigle page sites.

    site-3 contains child and grandchild pages.

    I want the same nav to appear on each page showing the sites and the child/grandchild pages.

    I have it working to the child pages of site-3 but I can’t display the grandchild pages.

    I’m using wp_get_pages because I don’t want a ul list but to have it in div’s

    The wp_get_pages works on the child pages.

    I’m then trying to use a second wp_get_pages to show the grandchild pages while in the foreach loop of the first wp_get_pages.

    Is it possible to show the grandchild pages using this method.

    Any help would be greatly appreciated.

    <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="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;
                            $className = str_replace(' ', '', $name);
                            $strclassName = strtolower($className);
                            $id = $details->blog_id;
    
                            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; ?> <?php echo $strclassName; ?>" >
                                <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){
                                        //show the nav for blog 4
    
                                        switch_to_blog(4);
    
                                        $pages_args = array(
                                            'exclude' => 2,
                                            'sort_column' => 'menu_order',
                                            'parent' => 0,
                                        );
    
                                        $pages = get_pages($pages_args);
    
                                        echo '<div class="subNav">';
    
                                        foreach ($pages as $page){
    
                                            echo '<div class="subNav__section">';
    
                                            echo '<h2>' .$page->post_title . '</h2>';
    
                                            $this_args = array(
                                                //'sort_order' => 'DESC',
                                                'hierarchical' => 1,
                                                'sort_column' => 'menu_order',
                                            );
    
                                            $inner_pages = get_pages($this_args);
    
                                            foreach($inner_pages as $inner_page){
    
                                                echo '<div>' .$page->post_title . '</div>';
    
                                            }
    
                                            echo '</div>';
    
                                        }
    
                                        echo '</div>';
    
                                        restore_current_blog();
    
                                    }
    
                                ?>
                            </li>
    
                            <?php
                            }
                        }
                    }
                    ?>
                    </ul>
                    <?php
    
                }
                ?>
            </div><!--/.nav-collapse -->
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘WordPress Multisite Naviagtion, child and grandchild pages’ is closed to new replies.