简体   繁体   English

WordPress的类别>帖子排序

[英]Wordpress Category > Posts Orderby

I am trying to order the posts by title, but i just cant get it to work, I have tried to insert orderby to query_posts but I dont think i get the logic of how you write query_posts values when you can add more then one setting with &. 我试图按标题对帖子排序,但是我无法使其正常工作,我试图将orderby插入到query_posts中,但是当您可以添加更多然后一个设置时,我不认为我理解了如何编写query_posts值的逻辑&。

Here is my code. 这是我的代码。

<?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 } ?>

Really thanks if you can help!! 真的谢谢你能帮忙!

I find that passing an associative array makes it a little easier to digest. 我发现传递一个关联数组会使它更容易消化。 Try this: 尝试这个:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM