WordPress.org

Ready to get started?Download WordPress

Forums

Use query_posts with multiple post_ids? (6 posts)

  1. ramonhimera
    Member
    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
    Member
    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
    Member
    Posted 5 years ago #

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

  4. buchannon
    Member
    Posted 5 years ago #

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

  5. andreacimatti
    Member
    Posted 5 years ago #

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

    query_posts('post_id=$postid')

    it is not pretty but it works

  6. design_dolphin
    Member
    Posted 5 years ago #

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

    http://codex.wordpress.org/Conditional_Tags

    '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