Random post for sidebar in certain category
After the 2.3 upgrade i am having problems with the code that i have for random posts to be displayed in the sidebar.
<?php global $wpdb; $random_posts = $wpdb->get_results("SELECT * FROM $wpdb->posts , $wpdb->terms WHERE $wpdb->terms.magazine = '1' AND term_id = '2' AND post_status = 'publish' ORDER BY RAND() LIMIT 1"); if($random_posts) : foreach($random_posts as $post) : setup_postdata($post); ?>
the code is now showing non published articles and ‘pages’.
I have added another column to the terms table so i can easily do this random article from the archives.
Can anyone help?
- The topic ‘Random post for sidebar in certain category’ is closed to new replies.