2011-07-13 24 views
4

是在WordPress自定義分類顯示所有類別和崗位聯繫起來,以及他們的任何方式意味着:的wordpress顯示所有自定義標籤和他們的助理崗位

my category1 
post 1 
post 2 
post 3 
post 4 


my category2 
post 1 
post 2 
post 3 
post 4 

注意到我必須這樣做,在自定義後的類型,分類。

+0

是這裏的任何人幫助我在這種情況下。 – Abdullah

+0

如果有人能幫助,我提供+100從我的聲譽。謝謝 – Uffo

+0

你可以更精確一點?你想完成什麼?您想要列出分類法的所有項目以及下面包含在此分類法中的所有後期項目? 爲什麼不使用標準的wordpress分類函數和嵌套的自定義查詢? – Blackbam

回答

3

這應該工作,我沒有測試它徹底

$args = array (
    'type' => 'post', //your custom post type 
    'orderby' => 'name', 
    'order' => 'ASC', 
    'hide_empty' => 0 //shows empty categories 
); 
$categories = get_categories($args); 
foreach ($categories as $category) {  
    echo $category->name; 
    $post_by_cat = get_posts(array('cat' => $category->term_id)); 

    echo '<ul>'; 
    foreach($post_by_cat as $post) { 
     setup_postdata($post); 
     echo '<li><a href="'.the_permalink().'">'.the_title().'</a></li>'; 
    } 
    echo '</ul>'; 
} 

來源:
http://codex.wordpress.org/Function_Reference/get_categories
http://codex.wordpress.org/Template_Tags/get_posts

問題,只是問

相關問題