How to create a loop to get all the posts of the network multisites wordpress

0
        <?php


        $sites = get_sites ();
        //percorre os sites
        foreach ($sites as $site) {
            //seleciona o site através do ID
            switch_to_blog ($site->blog_id);




        if ( have_posts() ) {
            while ( have_posts() ) {
            the_post();
                    echo '<article class="col-12">';
                    echo  '<div class="card" style="width: 21rem;">';

                        if(has_post_thumbnail()){

                            ?>
                                <a href=" <?php the_permalink();?>" class="card-img-top" src="" alt="Card image cap"><?php the_post_thumbnail('thumbnail');?></a>
                                <?php
                            } 

                        echo' <div class="card-body">';?>
                            <h5 class="card-title"><?php the_title()?></h5>
                            <p class="card-text"><?php the_excerpt()?></p>
                            <a href="<?php the_permalink()?>" class="btn btn-primary">Saiba mais</a>
                        <?php echo' </div>';


                            echo'</article>';    

                }

                wp_reset_postdata();     

            }else{
                get_template_part('no-results');
            } 

        }
        ?>
        <div class="navigation">
            <?php previous_posts_link( __( 'Newer posts' ) ); ?>
            <?php next_posts_link( __( 'Older posts' ) ); ?>    



        <?php  


        ?>
    
asked by anonymous 27.06.2018 / 04:20

0 answers