Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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(); ?>
                </a>
            </h2>

            <?php the_excerpt(); ?>

            <div class="clear"></div>
        </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
add comment

1 Answer

up vote 1 down vote accepted

Yes, use "post__in", a example:

<?php
$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
add comment

Your Answer

 
discard

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.