【发布时间】:2012-03-08 00:34:56
【问题描述】:
我有一个 taxonomy-tools.php 页面,它仅使用简单的循环(如果有帖子...等)。
我正在寻找一种按字母顺序对这些结果进行排序并显示超过 10 个帖子的方法。
我尝试使用 query_posts,但我得到了该帖子类型的所有结果,而不仅仅是分类。
【问题讨论】:
我有一个 taxonomy-tools.php 页面,它仅使用简单的循环(如果有帖子...等)。
我正在寻找一种按字母顺序对这些结果进行排序并显示超过 10 个帖子的方法。
我尝试使用 query_posts,但我得到了该帖子类型的所有结果,而不仅仅是分类。
【问题讨论】:
你有没有尝试过类似的东西
$args = array(
'post_type'=> 'custom-post-type',
'order' => 'ASC',
'orderby' => 'title',
'tag' => 'your-custom-post-tag', // use this if its a tag
'cat' => 'your-custom-category', // use this is its a category
'posts_per_page' => 30,
'post_status' => 'publish'
);
query_posts( $args );
那么就使用你一直在使用的基本循环吗?
【讨论】:
(have_posts()) : while (have_posts()) : the_post();。如果我删除 query_posts 它可以工作,但只显示按日期排序的 10 个帖子。