Title: Query with array and showposts
Last modified: August 22, 2016

---

# Query with array and showposts

 *  [zepokpok](https://wordpress.org/support/users/zepokpok/)
 * (@zepokpok)
 * [11 years, 7 months ago](https://wordpress.org/support/topic/query-with-array-and-showposts/)
 * Hello there,
 * I try to limit a query with showing only 5 posts.
 * It looks like that :
 *     ```
       <?php
       					$highlights_category = get_category( ot_get_option( 'highlights_category', '0' ) );
       					if( !empty( $highlights_category ) ){
       					    if (isset($highlights_category->slug)) {
           					    $highlights_category = $highlights_category->slug;
       					    } else {
           					    $highlights_category = 'evenements';
       					    }
   
       					}else{
       						$highlights_category = 'evenements';
       					}
       					$args = array(
       						'posts_per_page' => 5,
       						'category_name' => $highlights_category
       					);
       				?>
       				<?php query_posts( '$args' ); // begin query ?>
       					<?php //begin loop for highlights content ?>
       					<?php if( have_posts() ){ ?>
       						<?php while( have_posts() ){ ?>
       							<?php the_post(); ?>
       ```
   
 * that doesn’t work (alwaays have many posts)
    I tried ‘showposts’ => ‘5’, too,
   with the same result.
 * Thank your for your help !

The topic ‘Query with array and showposts’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [zepokpok](https://wordpress.org/support/users/zepokpok/)
 * Last activity: [11 years, 7 months ago](https://wordpress.org/support/topic/query-with-array-and-showposts/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
