I'm wondering how to display 4 random posts on a template page. I've seen a couple of other posts about this, but none seem to do what I want it to do. I'm not exactly sure how to get the loop to work in the page and I also want it to only randomly display the posts, not the pages. Do I have to use the query post function?
Would this work (taken from another thread)?
<?php $rand_id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'post' ORDER BY RAND() LIMIT 1"); $my_query = new WP_Query("p=$rand_id"); ?>