WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] Display posts using post IDs in an array?

[Resolved] Display posts using post IDs in an array?

  • I have sorted an array of post IDs based on multiple custom fields/values, for example…
    Array ( [0] => 804 [1] => 771 [3] => 765 [4] => 784 [5] => 807 )

    but now I have no idea how to display these posts IN THIS ORDER using this array.

    Help?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Solved using post__in

    $myarray = array_unique($result, SORT_NUMERIC);
    print_r($myarray);
    
    query_posts( array(
       'orderby' => 'ID',
        'post__in' => $myarray,
                            ) );

    EDIT….. that’s not working for me. Any ideas where I’m going wrong?

    AHHHHHHHHHHHHH HA…

    query_posts( array( 'post__in' => $myarray, 'orderby' => 'post__in' ) );

    (duh!)

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘[Resolved] Display posts using post IDs in an array?’ is closed to new replies.