Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/drupal/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Wordpress-嵌套WP_查询循环重复内容_Php_Wordpress_Loops - Fatal编程技术网

Php Wordpress-嵌套WP_查询循环重复内容

Php Wordpress-嵌套WP_查询循环重复内容,php,wordpress,loops,Php,Wordpress,Loops,我有一个嵌套的wordpress循环来生成两列布局,其中包含两个不同类别的内容。所发生的事情是内容被复制,但所有的帖子都被显示出来。我尝试过使用wp\u reset\u query()和wp\u reset\u postdata(),但没有成功。有办法吗 <?php $main = new WP_Query( array( 'post_type' => 'post', 'category_name' => 'Notizie varie', 'p

我有一个嵌套的wordpress循环来生成两列布局,其中包含两个不同类别的内容。所发生的事情是内容被复制,但所有的帖子都被显示出来。我尝试过使用
wp\u reset\u query()
wp\u reset\u postdata()
,但没有成功。有办法吗

<?php 
$main = new WP_Query(
    array(
    'post_type' => 'post',
    'category_name' => 'Notizie varie',
    'posts_per_page' => 6    
    )
);
//var_dump( $main );
    if( $main->have_posts() ): 
        while( $main->have_posts() ): $main->the_post(); 
?>
    <div class="col-8 p-4 mt-3">
        <img class="card-img-top" src="<?php echo the_post_thumbnail_url(); ?>">
        <h4 class="card-title"><?php the_title(); ?></h4>
        <p class="card-text"><?php echo get_the_excerpt( get_the_ID() ); ?></p> 
        <small class="text-muted"><?php echo get_the_date( get_the_ID() ) ?></small> 
        <small class="text-muted"><?php the_author() ?></small> 
        <a class="" href="<?php the_permalink(); ?>"><?php _e('Leggi', ''); ?></a> 
    </div>
<?php
        $side = new WP_Query(
            array(
            'post_type' => 'post',
            'category_name' => 'Secondo piano',
            'posts_per_page' => 6    
            )
        );
    if( $side->have_posts() ): 
        while( $side->have_posts() ): $side->the_post();
?>
    <div class="col-4 p-4 mt-3">
        <img class="card-img-top" src="<?php echo the_post_thumbnail_url(); ?>">
        <h4 class="card-title"><?php the_title(); ?></h4>
        <p class="card-text"><?php echo get_the_excerpt( get_the_ID() ); ?></p>
        <small class="text-muted"><?php echo get_the_date( get_the_ID() ) ?></small> 
        <small class="text-muted"><?php the_author(); ?></small> 
        <a class="" href="<?php the_permalink(); ?>"><?php _e('Leggi', ''); ?></a> 
    </div>
<?php 
        endwhile; 
        wp_reset_query();
    endif; 
        endwhile;
    endif;
        wp_reset_postdata();

">

">