2013-03-06 242 views
0

我想按標題排序,但我只是不能得到它的工作,我試圖插入orderby到query_posts,但我不認爲我得到如何寫query_posts值的邏輯時您可以使用&添加多個設置。Wordpress分類>帖子Orderby

這是我的代碼。

<?php 
$cat_id = get_query_var('cat'); 
$catlist = get_categories('hide_empty=0&child_of=' . $cat_id); 
$cat_child = get_field('frontend_name' , 'category_' . get_query_var('cat')); 

foreach($catlist as $categories_item) { 
    echo "<ol>"; 
    echo '<h3><a href="' . get_category_link($categories_item->term_id) . '" ' . '>' . $categories_item->description .'</a> </h3> '; 
    query_posts("cat=" . $categories_item->term_id . "&post_per_page=9999"); 

if (have_posts()) : while (have_posts()) : the_post(); ?> 
    <li><a href="<?php the_permalink();?>"> 
     <?php the_title(); ?> 
    </a></li> 
<?php endwhile; endif; ?> 
<?php echo "</ol>"; ?> 
<?php } ?> 

真的很感謝你能幫忙!!

回答

0

我發現傳遞一個關聯數組使得它更容易消化。試試這個:

// Refactored query arguments 
query_posts(array(
    'cat' => $categories_item->term_id, 
    'posts_per_page' => 9999, 
    'order' => 'ASC', //order ascending 
    'orderby' => 'title' //order by title 
)); 
相關問題