Title: List Posts by Tag
Last modified: August 19, 2016

---

# List Posts by Tag

 *  [rollotamasi](https://wordpress.org/support/users/rollotamasi/)
 * (@rollotamasi)
 * [16 years, 2 months ago](https://wordpress.org/support/topic/list-posts-by-tag/)
 * Hi guys,
    I have a number of posts in a sub-category, approximately 100 in total.
   I want to use the 6 or so most popular posts and link to them as a menu.
 * I’m hoping I can do this by tagging the 6 posts with a tag such as “important”
   and then use some form of query or loop to list all posts tagged with “important”.
 * Is this possible?

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

 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [16 years, 2 months ago](https://wordpress.org/support/topic/list-posts-by-tag/#post-1369510)
 * Well, natively, when a user clicks on a tag link presented via a Tag Cloud Widget,
   or a display `the_tags` with each of your posts, then WordPress will automatically
   list all the posts with that tag.
 * See [Tag Templates](http://codex.wordpress.org/Tag_Templates), [Template Hierarchy](http://codex.wordpress.org/Template_Hierarchy),
   [the_tags()](http://codex.wordpress.org/Template_Tags/the_tags), and [wp_tag_cloud()](http://codex.wordpress.org/Template_Tags/wp_tag_cloud).
 * But this could be used in a template such as a sidebar.php or page template:
 *     ```
       <?php
       $term = get_term_by('slug','important', 'post_tag');
       $args=array(
         'tag__in' => array($term->term_id),
         'post_type' => 'post',
         'post_status' => 'publish',
         'posts_per_page' => -1,
         'caller_get_posts'=> 1
       );
       $my_query = null;
       $my_query = new WP_Query($args);
       if( $my_query->have_posts() ) {
         echo 'List of Posts in tag '. $term->description;
         while ($my_query->have_posts()) : $my_query->the_post(); ?>
           <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
           <?php
         endwhile;
       }
       wp_reset_query();  // Restore global post data stomped by the_post().
       ?>
       ```
   
 *  [simpleflair](https://wordpress.org/support/users/simpleflair/)
 * (@simpleflair)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/list-posts-by-tag/#post-1369716)
 * is there a way to limit to show only 5 on the list rather than every post under
   a specific tag?
 *  [esmi](https://wordpress.org/support/users/esmi/)
 * (@esmi)
 * [15 years, 11 months ago](https://wordpress.org/support/topic/list-posts-by-tag/#post-1369717)
 * Try using:
 *     ```
       $args=array(
         'tag__in' => array($term->term_id),
         'post_type' => 'post',
         'post_status' => 'publish',
         'posts_per_page' => 5,
         'caller_get_posts'=> 1
       );
       ```
   

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

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 4 participants
 * Last reply from: [esmi](https://wordpress.org/support/users/esmi/)
 * Last activity: [15 years, 11 months ago](https://wordpress.org/support/topic/list-posts-by-tag/#post-1369717)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
