I have an array full of message identifiers, such as $post_id = array(3,56,89,98);Now I just need to display the message details in a table format. How can I build a loop for wordpress here? I apologize for my newcomers to Wordpress and be gentle. I really need some direction.
$post_id = array(3,56,89,98);
I also started learning php all you need to do something like
foreach ($post_id as $id) { // do what ever you want to do here }
Edit
<?php $post_id = array(3,56,89,98); $posts = get_posts( $post_id); foreach( $posts as $post ) : setup_postdata($post); ?> // you can call use post data inside here like <h2 class="title"><?php the_title(); ?></h2> <?php endforeach; ?>
In fact, I think something is wrong with Umesh's answer. Instead:
It should be:
$post_id = array( 'post__in' => array(3,56,89,98) );
Right?
, query_posts. - query_posts( array( 'post__in' => $post_id ) ); .
query_posts( array( 'post__in' => $post_id ) );
WP_Query .