WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Display posts using post IDs in an array? (3 posts)

  1. debsch
    Member
    Posted 1 year ago #

    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?

  2. debsch
    Member
    Posted 1 year ago #

    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?

  3. debsch
    Member
    Posted 1 year ago #

    AHHHHHHHHHHHHH HA...

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

    (duh!)

Topic Closed

This topic has been closed to new replies.

About this Topic