i want to show posts from my sub-directory in one page with wp_quary loop.so i try this code

<?php   require($_SERVER['DOCUMENT_ROOT'] . '/picture/wp-load.php'); 
    $args = array(
                // 'cat' => 3, // Only source posts from a specific category
        'posts_per_page' => 10 // Specify how many posts you'd like to display
    );
    $latest_posts = new WP_Query( $args );  
    if ( $latest_posts->have_posts() ) {
        while ( $latest_posts->have_posts() ) {
            $latest_posts->the_post(); ?>

<li><div class="media"> <a class="media-left" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"> 

<?php if ( has_post_thumbnail() ) { ?> <?php the_post_thumbnail(); ?> <?php } ?> </a>

<div class="media-body"> <a class="catg_title" href="<?php the_permalink(); ?>"> <?php the_title(); ?></a></div></div>
</li>
<? } } else { echo '<p>There are no posts available</p>'; } wp_reset_postdata(); ?>

Then again in another place but same page i use same code but i want to show posts from different folder means different wp site.

<?php   require($_SERVER['DOCUMENT_ROOT'] . '/video/wp-load.php'); 
    $args = array(
                // 'cat' => 3, // Only source posts from a specific category
        'posts_per_page' => 10 // Specify how many posts you'd like to display
    );
    $latest_posts = new WP_Query( $args );  
    if ( $latest_posts->have_posts() ) {
        while ( $latest_posts->have_posts() ) {
            $latest_posts->the_post(); ?>

<li><div class="media"> <a class="media-left" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"> 
<?php if ( has_post_thumbnail() ) { ?> <?php the_post_thumbnail(); ?> <?php } ?> </a>

<div class="media-body"> <a class="catg_title" href="<?php the_permalink(); ?>"> <?php the_title(); ?></a></div></div>
</li>
<? } } else { echo '<p>There are no posts available</p>'; } wp_reset_postdata(); ?>

But problem is its showing posts from picture forlder. in this way, i use several folder but every folder show posts from 1st folder. how can i close first folder then show 2nd folder’s posts?

Read more here: Show posts in one page from different wordpress installs


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: