<?php
global $wpdb;
$numposts = 1;
$rand_posts = $wpdb->get_results(“SELECT * FROM $wpdb->post2cat,$wpdb->posts,$wpdb->categories WHERE
$wpdb->post2cat.post_id = $wpdb->posts.ID and $wpdb->post2cat.category_id = $wpdb->categories.cat_ID and $wpdb->posts.post_status = ‘publish’ and $wpdb->categories.cat_name = ‘featured’ ORDER BY RAND() LIMIT $numposts”);
foreach($rand_posts as $post) :
setup_postdata($post);
?>
Hi Everyone, this code works find and I am now getting random posts for category “featured”
How do I take this one step further and show random post from whichever category im currently in?
Now if I click on another category other than featured i still get the ramdom posts from featured.
On home page it would show randon form every category, and when in a category it would show category specific