当类别slug设置为“全部”时,是否可以更改WP_Query参数并显示所有帖子。抓取单个类别中帖子的功能位于何处。?
因此,对于以下URL,它将显示所有类别中的所有帖子。
mysite.com/category/all
如果你想显示所有帖子,你可以使用 wp_query 过滤所有帖子。以下是一个自定义示例 wp_query 使用分页:
wp_query
<?php $all_post_query = new WP_Query( array( 'post_type'=>'post', 'post_status'=>'publish', 'posts_per_page'=> 10, 'paged' => $paged ) ); ?>
然后你可以循环浏览并获取帖子
<?php while ( $all_post_query->have_posts() ) : $all_post_query->the_post(); the_title(); //more code here ?>