Title: List Posts by Category
Last modified: August 18, 2016

---

# List Posts by Category

 *  [JakeThePeg](https://wordpress.org/support/users/jakethepeg/)
 * (@jakethepeg)
 * [18 years, 11 months ago](https://wordpress.org/support/topic/list-posts-by-category/)
 * Good morning/arvo/eve,
 * I would like to create a “Sitemap” of my blog.
 * I have created a page called “sitemap”, and have a plugin which allows me to 
   embed php code directly into pages/posts.
 * Now I require the php code which will enable me to list every single post as 
   a hyperlink, ordered by category.
 * **For example:**
 * > Category #1
   >  Post #1a Post #1b Category #2 Post #2a Post #2b Post #2c etc etc
 * I would also like to know how to exclude particular categories.

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

 *  [moshu](https://wordpress.org/support/users/moshu/)
 * (@moshu)
 * [18 years, 11 months ago](https://wordpress.org/support/topic/list-posts-by-category/#post-572093)
 * [http://www.dagondesign.com/articles/sitemap-generator-plugin-for-wordpress/](http://www.dagondesign.com/articles/sitemap-generator-plugin-for-wordpress/)
 *  [dondiego2007](https://wordpress.org/support/users/dondiego2007/)
 * (@dondiego2007)
 * [18 years, 9 months ago](https://wordpress.org/support/topic/list-posts-by-category/#post-572423)
 * mmmh, I have done all the suggested changes but it doesn’t work. may be there
   are different ‘polyglot’ plugins? if someone reads… tks in advance
 *  [Manalishi](https://wordpress.org/support/users/manalishi/)
 * (@manalishi)
 * [18 years, 3 months ago](https://wordpress.org/support/topic/list-posts-by-category/#post-572507)
 * I had trouble finding the answer to this one but finally did. Here is the code
   to list posts by category in your sidebar:
 *  ‘<!–Show posts by category–>
    <?php if (in_category(‘4’)) : ?> <?php $my_query
   = new WP_Query(‘cat=4&showposts=15’); ?> <?php while ($my_query->have_posts()):
   $my_query->the_post(); ?>
    - <br/>
    -  <?php endwhile; ?>
    -  <?php endif; ?>
       <!–End Show posts by category–> ‘

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

The topic ‘List Posts by Category’ is closed to new replies.

## Tags

 * [by](https://wordpress.org/support/topic-tag/by/)
 * [category](https://wordpress.org/support/topic-tag/category/)
 * [list](https://wordpress.org/support/topic-tag/list/)
 * [posts](https://wordpress.org/support/topic-tag/posts/)

 * 3 replies
 * 4 participants
 * Last reply from: [Manalishi](https://wordpress.org/support/users/manalishi/)
 * Last activity: [18 years, 3 months ago](https://wordpress.org/support/topic/list-posts-by-category/#post-572507)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
