Never under any circumstances use query_posts
. There is no excuse.
Use WP_Query instead. According to the WP_Query documentation, post_type
accepts a value of 'any'
.
$ids = array(2101,3754,4760,2572);
$query = new WP_Query(array(
'post_type' => 'any',
'post__in' => $ids,
'posts_per_page' => 4
));
if ( $query->have_posts()) {
while( $query->have_posts() ) {
$query->the_post();
the_title(); // etc
}
wp_reset_postdata(); // cleanup after our query
}
You also set it to return 1 post per page, but since you’re not dealing with pagination, you want 4 posts, not 1, so increase that to 4
I would also advise against hardcoding your post IDs. A category name may be a better choice, or a ‘featured items’ taxonomy thats shared across both pages and posts, or better yet, a post meta value, with a metabox with a checkbox in it. All of which are subjects for other questions