At this time, I am doing:

$posts = get_posts(array('post_type' => 'page', 'post__in' => array(1, 3, 2, 9, 7)));

and am getting two issues:

  1. Publish 3 is of 'post_type' => 'post', therefore it does not get selected, however i need it! Basically omit 'post_type' => 'page', then only publish 3 is chosen (since it must assume 'post_type' => 'post'.).
  2. I wish to have the ability to order the posts arbitrarily by their ids. Basically understood using MySQL, I possibly could do:

    SELECT * FROM wp_posts WHERE ID IN (1, 3, 2, 9, 7)
    ORDER BY FIND_IN_SET(ID, '1,3,2,9,7');
    

But, how must i do that with WordPress?

First fetch all posts randomly by their ids after which loop through all of the posts

That you can do in by doing this:-

$posts=$wpdb->get_results("SELECT ID FROM $wpdb->posts WHERE ID IN (1, 3, 2, 9, 7)
ORDER BY FIND_IN_SET(ID, '1,3,2,9,7')");
$count=count($posts);
for ($counter=0 ; $counter < $count; $counter++)
{
   $post=get_post( $posts[$counter]->ID, $output );
  //do your stuffs with posts
}

Hope this can help

  1. Kawauso around the #wordpress IRC funnel informed me that "publish_type takes a range of values." From that, I discovered the following also chooses publish 3:

  2. So, Used to do the next:

    $post_ids = array(1 => 0, 3 => 1, 2 => 2, 9 => 3, 7 => 4);
    $posts = get_posts(array('post_type' => array('post', 'page'),
                             'post__in' => array_keys($post_ids)));
    $ordered_posts = array(0,0,0,0,0); // size of five; keeps order
    foreach ($posts as $p) {
      setup_postdata($p);
      $ordered_posts[$post_ids[$p->ID]] = array(
        'permalink' => get_permalink($p->ID),
        'title' => $p->post_title,
        'excerpt' => get_the_excerpt(),
        'date' => date('F j, Y', strtotime($p->post_date)));
    }
    

Based on this thread, this can be used code after which make use of the classic WordPress loop:

$args = array(
'post_type'=>'page',
'orderby'=>'menu_order',
'order'=>'ASC'
);
query_posts($args);