johnheart
Forum Replies Created
-
Forum: Themes and Templates
In reply to: IE7 & CSSsame problem in IE7.
Forum: Plugins
In reply to: Ancestor styling added to Fold Category ListThis plugin includes drafts and pages as General category. How can we fix this? Thanks.
Forum: Plugins
In reply to: One Random Post (not random list or link)This is the modified code and it works except that pages and drafts also show in random posts. Anyone knows how to exclude it? Thanks.
<?php
global $wpdb;
$numposts = 3;
$now = date('Y-m-d') . ' 23:59:59';
$rand_posts = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_status = 'publish' AND post_end_date >= '$now' OR post_end_date IS NULL ORDER BY RAND() LIMIT $numposts");
foreach($rand_posts as $post) :
setup_postdata($post);
?>
~Post-related code and template tags go here. ~
<?php endforeach; ?>
Forum: Plugins
In reply to: display random posts on index pageThe code above also shows pages. How can I exclude it? Thanks.
Forum: Plugins
In reply to: display random posts on index pageI would like to specify categories to include and exclude. Thanks.
Forum: Plugins
In reply to: One Random Post (not random list or link)The link:
http://ww.wp.xz.cn/support/topic/91421#post-462158
is good. How can I specify the category? How can I insert this two codes:
1. $now = date(‘Y-m-d’) . ‘ 23:59:59’;
2. AND (post_end_date >= ‘$now’ OR post_end_date IS NULL)Forum: Plugins
In reply to: One Random Post (not random list or link)I have changed it to LIMIT 4 but it only shows me 1 post.
Forum: Plugins
In reply to: One Random Post (not random list or link)Repeat the codes above many times?
Forum: Plugins
In reply to: One Random Post (not random list or link)Using this code below:
<?php
$rand_id = $wpdb->get_var(“SELECT ID FROM $wpdb->posts WHERE post_status = ‘publish’ ORDER BY RAND() LIMIT 1”);
query_posts(“p=$rand_id”);
?>
<?php while (have_posts()) : the_post(); ?>~Post-related code and template tags go here. ~
<?php endwhile; ?>
How can I display more than one post? Thanks.