[Resolved] Random redirect to a given category
Hello guys, i recently needed to use random redirect, however ONLY to one category, edit your pluginfile, and set $random_id to this:
$random_id = $wpdb->get_var( "SELECT wp_posts.ID FROM $wpdb->posts, wp_term_relationships WHERE wp_posts.post_type = 'post' AND wp_posts.post_password = '' AND wp_posts.post_status = 'publish' AND wp_posts.ID = wp_term_relationships.object_id AND wp_term_relationships.term_taxonomy_id = 1 ORDER BY RAND() LIMIT 1");
replace the 1 that comes after term_taxonomy by your category id.
- The topic ‘[Resolved] Random redirect to a given category’ is closed to new replies.