Title: Show specific IDs with query_posts()
Last modified: August 19, 2016

---

# Show specific IDs with query_posts()

 *  [devaleur](https://wordpress.org/support/users/devaleur/)
 * (@devaleur)
 * [16 years, 5 months ago](https://wordpress.org/support/topic/show-with-query_posts/)
 * Hi
    Please there are someone who can tell me how can I select with query_posts()
   just the pages with ID 5, 143 and 145. Thanks..

Viewing 1 replies (of 1 total)

 *  [MichaelH](https://wordpress.org/support/users/michaelh/)
 * (@michaelh)
 * [16 years, 5 months ago](https://wordpress.org/support/topic/show-with-query_posts/#post-1282821)
 *     ```
       <?php
       $type='post'; //or $type='page'
           $args=array(
             'post_type' => $type,
             'post__in' => array(5,143,145),
             'caller_get_posts'=>1
           );
           $my_query = new WP_Query($args);
           if( $my_query->have_posts() ) {
             echo 'List of '. $type . '(s)';
             while ($my_query->have_posts()) : $my_query->the_post(); ?>
             <p> <?php the_category(', '); ?> -
             <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></p>
              <?php
             endwhile;
           } //if ($my_query)
         wp_reset_query();  // Restore global post data stomped by the_post().
       ?>
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Show specific IDs with query_posts()’ is closed to new replies.

## Tags

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

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 1 reply
 * 2 participants
 * Last reply from: [MichaelH](https://wordpress.org/support/users/michaelh/)
 * Last activity: [16 years, 5 months ago](https://wordpress.org/support/topic/show-with-query_posts/#post-1282821)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
