Right now I’m using the following code to display random posts on my site:
<?php $randomPost = $wpdb->get_var(“SELECT guid FROM $wpdb->posts WHERE post_type = ‘post’ AND post_status = ‘publish’ ORDER BY rand() LIMIT 1”);
echo ‘<span>Random Post</span>‘; ?>
I was wondering how this code can be altered to display random posts from a given category?
Thanks for your help!
- The topic ‘How to display random posts from a given category?’ is closed to new replies.