在查询帖子/数组中按字母顺序排列

时间:2014-02-19 17:45:43

标签: php wordpress if-statement echo posts

请有人告诉我如何按字母顺序排列这个? 我已经尝试了很多东西,似乎没什么用。

<?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(); ?>

1 个答案:

答案 0 :(得分:1)

尝试在args数组中指定orderby

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