如何在 Wordpress 中查询接下来的 2 个帖子


How to query the next 2 posts in Wordpress

但是,我希望在Wordpress中查询与当前位置相关的下两篇文章。

因此,例如,如果我在帖子 #1 上,则会显示帖子 #2 + #3。如果我在帖子 #7 上,则会显示帖子 #8 + #9。如果可能的话,我也希望这些循环播放,所以如果帖子 #9 是最后一篇文章,而我正在查看帖子 #8,我会看到帖子 #9 + #1。

有人可以帮我解决这个问题吗?

               <?php
                $args = array(
                    'post_type' => 'project',
                    'orderby' => 'date',
                    'order' => 'DESC',
                    'posts_per_page' => '2'
                );
                $query = new WP_Query( $args );
                ?>
                <?php if ( $query->have_posts() ) : ?>
                    <?php while ( $query->have_posts() ) : $query->the_post(); ?>
                        <div class="unit one-half">
                            <figure>
                                <?php if ( has_post_thumbnail() ) { 
                                      the_post_thumbnail();
                                } ?>
                            </figure>
                            <figcaption>
                                <h4><?php the_title(); ?></h4>
                                <h5><?php the_excerpt(); ?></h5>
                                <h6><a href="<?php the_permalink(); ?>">Read More</a></h6>
                            </figcaption>
                        </div>
                    <?php endwhile; ?>
                <?php endif; ?>
                <?php wp_reset_postdata(); ?>
<?php
    $paged = ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1;
    $args = array (
        'post_type' => 'post',
        'posts_per_page' => '2',
        'paged' => $paged,
        );  
    $wp_query = new WP_Query($args);
    while ($wp_query->have_posts()): $wp_query->the_post();
    get_the_title();
    endwhile;
    global $wp_query;
    $big = 999999999; // need an unlikely integer
    echo paginate_links( array(
        'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
        'format' => '?paged=%#%',
        'current' => max( 1, get_query_var('paged') ),
        'total' => $wp_query->max_num_pages
    ) );
?>