Title: Display posts from specific category
Last modified: August 22, 2016

---

# Display posts from specific category

 *  Resolved [c-m](https://wordpress.org/support/users/c-m/)
 * (@c-m)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/display-posts-from-specific-category-1/)
 * How do I list posts with a specific category?
 * More precisely, I want to display the featured image, title, and excerpt in the
   following format:
 *     ```
       <ul>
           	<li>
               	<img src="post image">
                   <div class="post-details-wrapper">
                   	<h3>Post title</h3>
                       <p>Post excerpt/p>
                   </div>
               </li>
       <li>
               	<img src="post image">
                   <div class="post-details-wrapper">
                   	<h3>Post title</h3>
                       <p>Post excerpt/p>
                   </div>
               </li>
       </ul>
       ```
   

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

 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/display-posts-from-specific-category-1/#post-5765184)
 * have you checked the topics from the forum search?
    [https://wordpress.org/search/list+posts+with+a+specific+category](https://wordpress.org/search/list+posts+with+a+specific+category)
 *  Thread Starter [c-m](https://wordpress.org/support/users/c-m/)
 * (@c-m)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/display-posts-from-specific-category-1/#post-5765192)
 * I don’t want to specify the category though. I want only to show the posts of
   the category that’s been clicked on.
 * At the moment I’ve got
 *     ```
       <ul>
       <?php
       $args = array(
         'orderby' => 'name',
         'order' => 'ASC'
         );
       $categories = get_categories($args);
         foreach($categories as $category) {
           	echo '<li>';
   
         	echo '<div class="post-details-wrapper">';
           echo '<h3><a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a> </h3> ';
           echo '<p>'. $category->description . '</p>';
           echo '</div>';
               echo '</li>';
   
            }
       ?>
       </ul>
       ```
   
 * But that just lists all categories, not list the posts within the selected category.
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/display-posts-from-specific-category-1/#post-5765197)
 * > I want only to show the posts of the category that’s been clicked on.
 * that would get automatically get done via the category archive template, possibly**
   category.php**, of your theme.
 * what theme are you using?
 *  Thread Starter [c-m](https://wordpress.org/support/users/c-m/)
 * (@c-m)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/display-posts-from-specific-category-1/#post-5765215)
 * I’m building one from scratch, and it’s category.php I’m working.
 * I’ve got most things down, I just can’t seem to understand the loop for categories.
 * I’m also trying to do a slight variation on this, where I display the sub categories
   of a main category, rather than the posts.
 * I think that is where I’m getting confused.
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/display-posts-from-specific-category-1/#post-5765221)
 * a general loop structure of a category.php for your desired html output would
   be:
 *     ```
       <?php if( have_posts() ) : ?>
       <ul>
       <?hp while( have_posts() ) : ?>
           	<li>
               	<?php the_post_thumbnail(); ?>
                   <div class="post-details-wrapper">
                   	<h3><?php the_title(); ></h3>
                       <?php the_ecerpt(); ?>
                   </div>
               </li>
       <?php endwhile; ?>
       </ul>
       <?php endif; ?>
       ```
   
 *  Thread Starter [c-m](https://wordpress.org/support/users/c-m/)
 * (@c-m)
 * [11 years, 3 months ago](https://wordpress.org/support/topic/display-posts-from-specific-category-1/#post-5765224)
 * Thanks very much. Just the same as a normal loop. I should have clocked that.

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

The topic ‘Display posts from specific category’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 6 replies
 * 2 participants
 * Last reply from: [c-m](https://wordpress.org/support/users/c-m/)
 * Last activity: [11 years, 3 months ago](https://wordpress.org/support/topic/display-posts-from-specific-category-1/#post-5765224)
 * Status: resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
