我有一个问题,关于显示类别帖子上的多个循环,我想从category=social 3设计位置的结构如下
Note: 我想要一个没有重复的帖子
这是我面临问题的代码
<?php
$args=array(
\'posts_per_page\' => 1,
\'category_name\' => \'social\'
);
$my_query = new WP_Query($args);
while ($my_query->have_posts()) : $my_query->the_post();
if( 1 > $wp_query->current_post ): ?>
<article class="post post--overlay post--overlay-xs post--overlay-floorfade post--overlay-bottom cat-1">
<?php
$image = get_the_post_thumbnail_url(get_the_ID(),\'full\');
?>
<div class="background-img" style="background-image: url(<?php echo $image; ?>)"></div>
<div class="post__text inverse-text">
<div class="post__text-wrap">
<div class="post__text-inner">
<h3 class="post__title typescale-2"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
</div>
</div>
</div>
</article>
<?php else: break; endif; endwhile; wp_reset_postdata(); ?>
<div class="spacer-xs"></div>
<ul class="list-space-xs list-seperated list-square-bullet-exclude-first list-unstyled">
<?php
$wp_query->current_post = 2;
while ( have_posts() ) : the_post();
?>
<li>
<article class="post--horizontal post--horizontal-xs cat-2">
<div class="post__thumb"><a href="<?php the_permalink(); ?>"><?php the_post_thumbnail( array( 100, 75 ) ); ?></a></div>
<div class="post__text">
<h3 class="post__title typescale-1"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
</div>
</article>
</li>
<?php endwhile; ?>
<?php
// Problem in showing the post in the third loop
while(have_posts()): the_post(); ?>
<li>
<article class="cat-4">
<div class="post-content">
<h3 class="post__title typescale-0"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
</div>
</article>
</li>
<?php endwhile; ?>
<?php ?>
</ul>
我从以下网站获得了帮助
Multiple Loops Homepage?