Title: List posts from current category
Last modified: August 19, 2016

---

# List posts from current category

 *  Resolved [gward1](https://wordpress.org/support/users/gward1/)
 * (@gward1)
 * [16 years, 3 months ago](https://wordpress.org/support/topic/list-posts-from-current-category/)
 * Hello,
 * I need to list all posts in the current category. I’ve tried using this:
 * <?php query_posts(‘posts_per_page=-1&orderby=title&order=ASC’); ?>
 * However it’s displaying all posts from all categories. Also looked here: [http://codex.wordpress.org/Template_Tags/query_posts](http://codex.wordpress.org/Template_Tags/query_posts)
   it says list the cat id’s but that option will not work because I have hundreds
   of subcategories. Help is appreciated. Thanks.

Viewing 3 replies - 1 through 3 (of 3 total)

 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [16 years, 3 months ago](https://wordpress.org/support/topic/list-posts-from-current-category/#post-1424039)
 * > Show One Category by ID
   > Display posts from only one category ID (a**nd any children of that category**):
   > query_posts(‘cat=4’);
 * [http://codex.wordpress.org/Template_Tags/query_posts](http://codex.wordpress.org/Template_Tags/query_posts)
 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [16 years, 3 months ago](https://wordpress.org/support/topic/list-posts-from-current-category/#post-1424040)
 * This example if just in case you don’t want child categories when visiting a 
   parent category and uses the WordPress Default theme…switch to the WordPress 
   Default theme. Then in the wp-content/themes/default folder create a file called
   category.php and put this code in that category.php:
 * [http://wordpress.pastebin.com/s5r6yExY](http://wordpress.pastebin.com/s5r6yExY)
 * Then visit your categories
 *  Thread Starter [gward1](https://wordpress.org/support/users/gward1/)
 * (@gward1)
 * [16 years, 3 months ago](https://wordpress.org/support/topic/list-posts-from-current-category/#post-1424056)
 * You’re a real swell guy MichaelH, did exactly what I needed. You can view the
   entire code for my category.php here: [http://wordpress.pastebin.com/JuBZ9Lbe](http://wordpress.pastebin.com/JuBZ9Lbe).
   I probably could have gotten rid of all those if elseif statements with something
   similar to what you did. There are hundreds of subcategories and tens of thousands
   of posts already. You can see an example of what I’m doing here: [http://www.songlyricsx.com/m/metallica/All-Nightmare-Long/](http://www.songlyricsx.com/m/metallica/All-Nightmare-Long/)(
   still a work in progress).

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘List posts from current category’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 3 participants
 * Last reply from: [gward1](https://wordpress.org/support/users/gward1/)
 * Last activity: [16 years, 3 months ago](https://wordpress.org/support/topic/list-posts-from-current-category/#post-1424056)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
