2016-10-03 68 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