所以我在分页和抵销方面遇到了麻烦,然后我决定使用一些规则来显示帖子,并且它起作用了。这里的问题是因为我需要以3种不同的方式显示帖子,当我使用偏移量时,我可以在每个WP_query中设置我不想显示的帖子的数量,如果使用if则容易得多,但我我被困在这里:
<div class="row">
<div class="col-12">
<?php
$paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1;
$query = new WP_Query(array('posts_per_page'=> 8, 'paged' => $paged));
if($query->have_posts()):
while($query->have_posts()):
$query->the_post();
$p++;
if($p==1 && $p%2==1):
?>
<!-- Post here -->
</div>
</div>
<section id="lasted-posts">
<div class="row" >
~ here ~
<div class="col-lg-8 col-md-8 col-sm-12">
<!-- Another post here -->
</div>
</div>
<div class="row">
~ here ~
<?php elseif ($p%2==0): ?>
<div class="col-md-4">
<!-- Normal post here -->
</div>
<?php endif; endwhile; endif; wp_reset_postdata(); ?>
</div>
<div class="row">
<div class="col-lg-12">
<div>
<?php wp_pagenavi( array( 'query' => $query ) ); ?>
<?php wp_pagination( array( 'query' => $query ) ); ?>
</div>
</div>
</div>
<?php
$p++;
if($p==1 && $p%2==1) :
?> do something
and
<?php
elseif ($p%2==0):
?>