显示文章从最近7天与分页


Show posts from last 7 days with pagination

我需要显示一个自定义的帖子类型已在过去7天发布的帖子。然后,我将有一个按钮,上面写着接下来的7天,用户可以点击,它将明显显示未来7天。

下面的代码似乎可以解决这个问题。我卡住的一件事是分页,它将如何显示未来7天?如有任何建议,我将不胜感激。

<?php $args = array(
    'post_type' => 'properties',
    'post_status' => 'publish',
    'orderby' => 'date',
    'order' => 'DESC',
    'date_query' => array(
        array(
            'after' => '1 week ago'
          )
      )
  ); ?>
  <?php $propertyInspection = new WP_Query( $args ); ?>
  <?php if ( $propertyInspection->have_posts() ) : ?>
    <?php while ( $propertyInspection->have_posts() ) : $propertyInspection->the_post(); ?>
    <?php the_field('property-address'); ?>
    <?php the_field('property-suburb'); ?>
   <?php endwhile; ?>
<?php endif; ?>

创建另一个$args数组与当前日期(或日期与未来7天)的按钮点击(提交),并获取未来7天的帖子相同。然后合并两个结果对象(也包括它们的post计数)