首页 > 解决方案 > 显示集合类别中的第二个和第三个最近的博客文章

问题描述

<?php
$args = array( 'numberposts' => 3, 'order'=> 'ASC', 'orderby' => 'title', 'category' => '136');
    $postslist = get_posts( $args );
    foreach ($postslist as $post) :  setup_postdata($post); ?> 
        <div class="col-webinar-blocks">
            <div class="list-card">
                <div class="list-card-content">
            <h3><?php the_title(); ?></h3>
            <p><?php the_field('list_view_description'); ?></p>
            <div class="list-card-button">More Info</div>
                    </div>
        </div>
             </div>
    <?php endforeach; ?>

我有上面的代码,它成功地从类别 ID 136 中提取了前 3 个博客。太棒了!

但是,有没有办法只通过第二和第三?我不想使用 css(如果可能的话。)

如何在 WordPress 中显示一个类别中的第二和第三个最新帖子- 这种工作但不会拉过我所追求的一个类别,而只是拉过所有帖子。

任何帮助深表感谢!

标签: phpwordpress

解决方案


推荐阅读