WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

At the moment I am working on a WP-site, which on the frontpages has 3 excerpts of other pages on it. The code I am trying to use for this is as following:

<?php query_posts(array('post_type' => 'page',
                            'include' => 5, 7, 52,
                            'showposts' => 3) ); ?>
    <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

        <div class="column">
            <h2 class="icon" id="page-column-id-<?php the_ID(); ?>">
                <a href="<?php the_permalink() ?>" rel="bookmark" title="<?php the_title(); ?>">
                    <?php the_title(); ?>

            <?php the_excerpt(); ?>

            <div class="clear"></div>

    <?php endwhile; else: ?>
        <p>Sorry, het bericht is niet gevonden.<br />Probeer het later nog eens..</p>
    <?php endif; ?>

Sadly, when I use this code I get a query for all the pages I have. Anyone has any idea how to get only the 3 pages on ID using this method?

Thnx in advance

share|improve this question
I found a fix already. After some more browsing through the wordpress-codex I found this nice string to add to the query in order to query page id's: 'post__in' => array(7, 16, 52) So that did the trick :) – ocm Jan 13 '12 at 9:58
up vote 1 down vote accepted

Yes, use "post__in", a example:

$ids = array(5, 7, 52);
query_posts(array('post_type' => 'page',
'post__in' => $ids,
'showposts' => 3) );
share|improve this answer
thnx :) This will do the trick aswell, however I found another solution – ocm Jan 23 '12 at 15:09

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.