Php Wordpress-嵌套WP_查询循环重复内容
我有一个嵌套的wordpress循环来生成两列布局,其中包含两个不同类别的内容。所发生的事情是内容被复制,但所有的帖子都被显示出来。我尝试过使用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
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();
">
">