2012-03-07 119 views
0

我有一个taxonomy-tools.php页面,显示(在url mysite.com/post-type/custom-taxonomy)来自该自定义分类的所有帖子,只使用简单的循环(如果有帖子...等)。自定义分类结果页面

我正在寻找一种按字母顺序排序这些结果并显示超过10个帖子的方法。

我试着用query_posts,但我得到的所有结果为该帖子类型,而不是仅为分类。

回答

0

喜你尝试过类似

$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); 

就用你已经使用基本的循环?

+0

感谢马蒂。我刚刚尝试过您的解决方案,但它一直显示所有帖子。示例:http://mysite.com/cattools/links/“cattools”是自定义分类名称,我有“链接”和“工具”,它们是“cattools”的分类,我将它们用作分类。如果我把“链接”或“cattools”作为“你的自定义类别”,它会显示我所有帖子类型(工具)的帖子。我使用的循环是'(have_posts()):while(have_posts()):the_post();'。如果我删除了query_posts它的作品,但只显示按日期排序的10篇文章。 – Andycap 2012-03-07 18:59:38