pulling 1 random post excluding a specific category in wordpress 2.3
-
hello,
I am trying to insert a code to create a random post in my homepage, excluding the categorie 46 using wordpress 2.3.1:<?php $not_this_cat = 46; $rand_id = $wpdb->get_var("SELECT ID FROM $wpdb->posts LEFT JOIN $wpdb->post2cat ON ID = post_id WHERE category_id <> $not_this_cat AND post_status = 'publish' ORDER BY RAND() LIMIT 1"); $wp_query->is_single = false; ?>
The problem is that the tag post2cat is outdated.
Someone could help with the new way to do
Thanks
Viewing 8 replies - 1 through 8 (of 8 total)
Viewing 8 replies - 1 through 8 (of 8 total)
- The topic ‘pulling 1 random post excluding a specific category in wordpress 2.3’ is closed to new replies.