• Resolved bdspice

    (@bdspice)


    hi, i want to show posts from multisite enable network. so here i try this in root index.php

    <?php require($_SERVER['DOCUMENT_ROOT'] . '/site/wp-load.php');
    global $switched; switch_to_blog(2); ?><ul><?php 
                $args = array(
                'post_type' => 'post',
                'posts_per_page' => 10,
                );
                $loop = new WP_Query( $args );
                while ( $loop->have_posts() ) : $loop->the_post(); ?>
            <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
            <?php endwhile; ?></ul><?php restore_current_blog(); ?>

    it is showing “Error establishing a database connection” can anyone help me in this? i am working on this over 2 week.

Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Show posts in one page from wp multisite network blogs’ is closed to new replies.