【问题标题】:Custom results on custom taxonomy page自定义分类页面上的自定义结果
【发布时间】:2012-03-08 00:34:56
【问题描述】:

我有一个 taxonomy-tools.php 页面,它仅使用简单的循环(如果有帖子...等)。

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

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

【问题讨论】:

    标签: wordpress taxonomy


    【解决方案1】:

    你有没有尝试过类似的东西

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

    那么就使用你一直在使用的基本循环吗?

    【讨论】:

    • 谢谢马蒂。我刚刚尝试了您的解决方案,但它一直显示所有帖子。示例:mysite.com/cattools/links“cattools”是自定义分类名称,我有“链接”和“工具”是“cattools”的分类,我将它们用作类别。如果我将“链接”或“cattools”作为“您的自定义类别”,它会显示所有帖子类型的帖子(工具)。我使用的循环是(have_posts()) : while (have_posts()) : the_post();。如果我删除 query_posts 它可以工作,但只显示按日期排序的 10 个帖子。
    猜你喜欢
    • 2021-05-17
    • 1970-01-01
    • 1970-01-01
    • 2016-11-07
    • 1970-01-01
    • 2012-08-06
    • 1970-01-01
    • 1970-01-01
    • 2019-02-25
    相关资源
    最近更新 更多