【问题标题】:Alphabetizing posts in query posts / array在查询帖子/数组中按字母顺序排列帖子
【发布时间】:2014-02-20 02:14:54
【问题描述】:

谁能告诉我如何按字母顺序排列? 我已经尝试了很多东西,但似乎没有任何效果。

<?php query_posts( array('post__not_in' => array(46,2401), 'cat' => $category_id,'posts_per_page'=>'-1')); ?>
    <?php while ( have_posts() ) : the_post();
        echo '<li';
        if (($ID = get_the_ID()) == $pagepostid) echo ' class="proadv-current-item"';
        //else echo ' class="post-id'.$ID.'-id'.$pagepostid.'"';
        echo '>';
        echo '<div class="sponsor-thumb">';
        echo '<a href="'.get_permalink().'">';
        the_post_thumbnail( 'category-thumb' );
        echo '</a>';
        echo '</div>';
        echo '<a href="'.get_permalink().'">';
        the_title();
        echo '</a>';
        echo '</li>';
    endwhile; ?>

    <?php wp_reset_query(); ?>

【问题讨论】:

  • 您是否指定排序?
  • 按名称按字母顺序对类别进行排序?
  • 我想按名称对帖子进行排序

标签: php wordpress if-statement echo posts


【解决方案1】:

尝试在 args 数组中指定 orderby

query_posts( array('post__not_in' => array(46,2401), 'cat' => $category_id,'posts_per_page'=>'-1','orderby'=>'name','order'=>'ASC'));

【讨论】:

  • 恐怕没有什么不同:(
  • 你还有什么想法吗?
猜你喜欢
  • 2011-06-17
  • 1970-01-01
  • 2012-11-02
  • 2014-10-13
  • 1970-01-01
  • 2019-03-14
  • 2019-02-08
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多