Title: post filtering/selection.
Last modified: August 21, 2016

---

# post filtering/selection.

 *  [agileArt](https://wordpress.org/support/users/pdxdaniela/)
 * (@pdxdaniela)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/post-filteringselection/)
 * After searching trough the forum and the various questions/answers i thought 
   this would help me w/my post selection issue.
 *     ```
       <ul>
       <?php query_posts('cat=seasonal&showposts=5'); ?>
       <?php while (have_posts()) : the_post(); ?>
       <li><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></li>
       <?php endwhile; ?>
       </ul>
       ```
   
 * I have two, out of six posts with a category of “seasonal” however the code above…
   that should work. Doesn’t. it brings in all the posts.
    What am I doing wrong
   please? Thank you D

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

 *  [Chris Olbekson](https://wordpress.org/support/users/c3mdigital/)
 * (@c3mdigital)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/post-filteringselection/#post-4455944)
 * The “cat” parameter is looking for a category ID or term_id. To use the category
   slug it should be `category_name=seasonal`.
 * Rather than using the query_posts function you should create a [new WP_Query instance](http://codex.wordpress.org/Class_Reference/WP_Query).
 *     ```
       $new_query = new WP_Query(
               array(
                   'cagtegory_name' => 'seasonal',
                   'posts_per_page' => 5
                )
           );
   
       while ( $new_query->have_posts() ) : $new_query->the_post();
       ```
   
 *  Thread Starter [agileArt](https://wordpress.org/support/users/pdxdaniela/)
 * (@pdxdaniela)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/post-filteringselection/#post-4455946)
 * Chris thank you very much.
    I did try get_post (i think) did not get anything
   at all back.
 * will try it (crossing fingers here)& report back.
    D
 *  Thread Starter [agileArt](https://wordpress.org/support/users/pdxdaniela/)
 * (@pdxdaniela)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/post-filteringselection/#post-4456015)
 * nope tried
 *     ```
       $new_query = new WP_Query(
               array(
                   'cagtegory_name' => 'seasonal',
                   'posts_per_page' => 5
                )
           );
   
       while ( $new_query->have_posts() ) : $new_query->the_post();
           echo '<li>';
           the_title();
           echo '</li>';
       endwhile;
       ```
   
 * and also
 *     ```
       <?php
       // The Query
       query_posts( 'cagtegory_name=seasonal&showposts=5' );
   
       // The Loop
       while ( have_posts() ) : the_post();
           echo '<li>';
           the_title();
           echo '</li>';
       endwhile;
   
       // Reset Query
       wp_reset_query();
       ?>
       ```
   
 * yes i know. but wanted to see if it worked. it didn’t.
 *  Thread Starter [agileArt](https://wordpress.org/support/users/pdxdaniela/)
 * (@pdxdaniela)
 * [12 years, 3 months ago](https://wordpress.org/support/topic/post-filteringselection/#post-4456017)
 * But this one did work:
 *     ```
       <?php
       $new_query = new WP_Query(
               'category_name=seasonal'
           );
       while ( $new_query->have_posts() ) : $new_query->the_post();
       ?>
   
       <li>
       	<h5><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h5>
       	<?php the_excerpt(); ?>
       	<hr>
       </li>
       <?php
       endwhile;
       ?>
       ```
   
 * however there is no limit on posts here.

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

The topic ‘post filtering/selection.’ is closed to new replies.

## Tags

 * [query_posts](https://wordpress.org/support/topic-tag/query_posts/)
 * [wp_query](https://wordpress.org/support/topic-tag/wp_query/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 4 replies
 * 2 participants
 * Last reply from: [agileArt](https://wordpress.org/support/users/pdxdaniela/)
 * Last activity: [12 years, 3 months ago](https://wordpress.org/support/topic/post-filteringselection/#post-4456017)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
