Ready to get started?Download WordPress


Use query_posts with multiple post_ids? (6 posts)

  1. ramonhimera
    Posted 6 years ago #

    I have scoured everywhere but cannot find the answer to a simple question.
    I would like to pass multiple post_ids to query_posts() and have tried...
    query_posts('post_id=1,2,3,4') but it doesnt work. I know you can pass multiples to get_post() but this doesnt support pagination. Please can you tell me if query_posts() supports multiple ids?

    Many Thx

  2. Aesqe
    Posted 6 years ago #

    You could check the query construct in 'query.php', in 'wp-includes' folder, but from what I've been able to decipher, query_posts(p=ID) works only for a single post...

  3. andreacimatti
    Posted 5 years ago #

    this is exactly what i've been trying to do for the past 3 hours. no luck yet.

  4. buchannon
    Posted 5 years ago #

    Did you ever figure this out? I could use it as well...

  5. andreacimatti
    Posted 5 years ago #

    What I did is I put the query_posts through a loop with a variable $postid


    it is not pretty but it works

  6. design_dolphin
    Posted 5 years ago #

    You need to use 'is_single' and then do your query.


    '2.4 A Single Post Page' in the table of contents on the right.

    Edit: or create a single template. See http://codex.wordpress.org/Theme_Development. You can create one for a single post id, or multiple id's by using the 'is_single' function.

    Of course if you want you can create more complex queries.

Topic Closed

This topic has been closed to new replies.

About this Topic