【发布时间】:2016-09-23 15:25:59
【问题描述】:
我需要显示过去 7 天内发布的自定义帖子类型的帖子。然后我会有一个按钮,上面写着 Next 7 days,用户可以点击它,它显然会显示接下来的 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; ?>
【问题讨论】: