Title: Sort posts alphabetically and exlude posts
Last modified: August 21, 2016

---

# Sort posts alphabetically and exlude posts

 *  [tommyleyland](https://wordpress.org/support/users/tommyleyland/)
 * (@tommyleyland)
 * [12 years, 4 months ago](https://wordpress.org/support/topic/sort-posts-alphabetically-and-exlude-posts/)
 * Does anyone know how to list these posts alphabetically? I’ve tried a number 
   of things and nothing seems to work?
 * I also need 2 posts excluding so if anyone knows how to do that also it would
   be great.
 * Code:
 *     ```
       <?php query_posts( array('cat' => $category_id,'posts_per_page'=>'-1', 'orderby'=> 'title', 'order' => 'ASC')); ?>
       		<ul id="ulposts2">
       		<?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">';
                   the_post_thumbnail( 'category-thumb' );
                   echo '</div>';
       		    echo '<a href="'.get_permalink().'">';
       		    the_title();
       		    echo '</a>';
       		    echo '';
       		endwhile; ?>
   
       		<?php wp_reset_query(); ?>
       ```
   
 * _[Moderator Note: Please post code & markup between backticks or use the code
   button. Your posted code may now have been permanently damaged by the forum’s
   parser.]_

The topic ‘Sort posts alphabetically and exlude posts’ is closed to new replies.

## Tags

 * [array](https://wordpress.org/support/topic-tag/array/)
 * [order](https://wordpress.org/support/topic-tag/order/)
 * [orderby](https://wordpress.org/support/topic-tag/orderby/)
 * [php](https://wordpress.org/support/topic-tag/php/)
 * [sortby](https://wordpress.org/support/topic-tag/sortby/)
 * [template](https://wordpress.org/support/topic-tag/template/)

 * 0 replies
 * 1 participant
 * Last reply from: [tommyleyland](https://wordpress.org/support/users/tommyleyland/)
 * Last activity: [12 years, 4 months ago](https://wordpress.org/support/topic/sort-posts-alphabetically-and-exlude-posts/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
