Modifying Matt’s Random Post Plugin
-
I want to modify Matt’s Random Post Plugin so that it displays post from a particular category?
This is the proginal query present in the plugin:
function matt_random_redirect() { global $wpdb; $random_id = $wpdb->get_var( "SELECT ID FROM $wpdb->posts WHERE post_type = 'post' AND post_password = '' AND post_status = 'publish' ORDER BY RAND() LIMIT 1"); wp_redirect( get_permalink( $random_id ) ); exit; } if ( isset( $_GET['random'] ) ) add_action( 'template_redirect', 'matt_random_redirect' ); ?>I am adding
AND post_category='2'in$random_id
but it start displaying only the same post again n again and donot randomize 🙁 ??
Viewing 9 replies - 1 through 9 (of 9 total)
Viewing 9 replies - 1 through 9 (of 9 total)
The topic ‘Modifying Matt’s Random Post Plugin’ is closed to new replies.