01-18-2008, 05:08 PM
|
#4 (permalink)
|
|
The Wanderer
Join Date: Dec 2007
Location: England
Posts: 15
Thanks: 6
|
Still trying to display random posts in wordpress, I have this working with the follwing:
Code:
<?php global $wpdb; $numposts = 40;
$rand_posts = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_status = 'publish' AND post_type = 'post' AND post_category != 1 ORDER BY RAND() LIMIT $numposts");
foreach($rand_posts as $post) : setup_postdata($post);
$title = $wp_query->post->post_title; $str = strtolower($title); $newtitle = str_replace(" ", "-", $str); ?>
<a href="<?php the_permalink() ?>" title="<?php the_title(); ?> Wallpaper"><img src="<?php echo get_option('siteurl'); ?>/images/160x120/<?php echo $newtitle ?>.jpg" alt="<?php the_title(); ?>" /></a>
<?php endforeach; ?>
However I want to exclude a category from getting pulled up. That category is the wordpress default - cat_ID=1.
Any suggestions?
Last edited by Dan : 01-18-2008 at 05:31 PM.
|
|
|
|