0

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

  • 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
1

Yes, use "post__in", a example:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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