2016-10-03 69 views
0

我在自定義WP theme.I工作需要表現出各個類別下的每個崗位,這是工作fine.But,我想按照帖子的發佈日期的類別進行排序。WordPress的:分類排序方式最新發布日期

我找到一個答案,但它不是在我的代碼工作,我不能圖如何在我的code.So使用它,我需要在下面的代碼任何人的專家的幫助/輸入。 Similar answer

 **<?php 
    $terms = get_terms(array(
     'taxonomy' => 'category', 
     'hide_empty' => false, 
     'orderby' => 'date', 
     'order' => 'ASC', 

    )); 

    foreach($terms as $cat){ 
     $cata_name = $cat->name; 
     $term_id = $cat->term_id; 
     $catqueryy = new WP_Query('cat='.$term_id.'&posts_per_page=10');$count = $catqueryy->found_posts;while($catqueryy->have_posts()) : $catqueryy->the_post();?>  


         <div class="list-group"> 
          <p class="post_excerpt"> 
          <?php echo ' <a href="'.home_url('index.php/category/'.$cata_name).'">'.__(get_the_title(),'rockon').'</a>'; ?> 
</div> 
<?php 
endwhile; 
?> 

回答

0

你可以試試這個按日期顯示所有類別

<?php $args = array(
    'show_option_all' => '', 
    'orderby'   => 'ID', 
    'order'    => 'DESC', 
); ?> 
<?php wp_list_categories($args); ?> 
+0

感謝的建議,但我想所有的類別進行排序。您的代碼將顯示列表中的類別..我想顯示所有類別的帖子... – Kxplorer