Forums

[resolved] How to retrieve multiple pages using query_posts? (6 posts)

  1. trex33
    Member
    Posted 4 months ago #

    According to codex, you can use query_posts to retrieve a specific page:

    <?php query_posts('page_id=7'); ?>

    So how do you retrieve multiple pages using query_posts? I tried this (which works fine when you retrieve posts for multiple categories):

    <?php query_posts('page_id=3,5,7'); ?>

    Unfortunately, this only retrieves page_id 3, not all of them. Any ideas?

  2. MichaelH
    moderator
    Posted 4 months ago #

    Try this:

    <?php
    $args = array(
      'post_type' => 'page',
      'post__in' => array(3,5,7)
      );
    query_posts($args);
    ?>
  3. trex33
    Member
    Posted 4 months ago #

    Perfect! Thanks as always Michael. I didn't even know post__in existed.

  4. JonBishop
    Member
    Posted 4 months ago #

    I was looking for this everywhere. Thanks so much.

  5. SAMsan
    Member
    Posted 3 months ago #

    TU soooo much :D

  6. weboncloud
    Member
    Posted 1 month ago #

    Thank you so much..this was very helpful

Reply

You must log in to post.

About this Topic