At first look it was simple, just:
1 2 3 4 5 6 7 8 |
$args = array("post__in" => array(1,2,3)); $posts = new WP_Query(); $posts -> query($args); while ($posts -> have_posts()){ $posts -> the_post(); echo the_title().'<br/>'; } wp_reset_postdata(); |
but, this way we can get ONLY posts, not pages. To get both posts AND pages just add:
1 |
'post_type'=>array('page', 'post') |
in WP_Query arguments list so it will look like this:
1 |
$args = array("post__in" => array(1,2,3), 'post_type'=>array('page', 'post')); |
And voila – we have both content types.