Title: query_posts loop through taxonomy and posts separately
Last modified: August 31, 2016

---

# query_posts loop through taxonomy and posts separately

 *  [plinth](https://wordpress.org/support/users/plinth/)
 * (@plinth)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/query_posts-loop-through-taxonomy-and-posts-separately/)
 * Hi, I have a custom post type with a taxonomy and several categories, with posts
   saved to each category. I want to create a page template that loops through the
   categories in turn, listing each post, like this:
 *     ```
       <h3>Custom Category One</h3>
       <ul>
       <li>Custom post 1</li>
       <li>Custom post 2</li>
       <li>Custom post 3</li>
       </ul>
   
       <h3>Custom Category Two</h3>
       <ul>
       <li>Custom post 4</li>
       <li>Custom post 5</li>
       <li>Custom post 6</li>
       </ul>
       ```
   
 * I can use `query_posts` to fetch all the custom posts and spit them out in one
   long list, but how do I loop through the categories one by one? Thanks in advance.

Viewing 1 replies (of 1 total)

 *  Thread Starter [plinth](https://wordpress.org/support/users/plinth/)
 * (@plinth)
 * [10 years, 3 months ago](https://wordpress.org/support/topic/query_posts-loop-through-taxonomy-and-posts-separately/#post-6990035)
 * Discovered I can use [this](https://codex.wordpress.org/Template_Tags/wp_list_categories#Display_Terms_in_a_custom_taxonomy)
   to loop through all the terms in a custom taxonomy, but it doesn’t go as far 
   as listing the posts within each taxonomy.
 * It’s close, but can any of you push it over the line?

Viewing 1 replies (of 1 total)

The topic ‘query_posts loop through taxonomy and posts separately’ is closed to 
new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 1 participant
 * Last reply from: [plinth](https://wordpress.org/support/users/plinth/)
 * Last activity: [10 years, 3 months ago](https://wordpress.org/support/topic/query_posts-loop-through-taxonomy-and-posts-separately/#post-6990035)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
