2012-03-07 81 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