我已经尝试了以下链接上的解决方案,但是,我无法让它们显示帖子!
http://codex.wordpress.org/Displaying_Posts_Using_a_Custom_Select_Query
http://wordpress.stackexchange.com/questions/1529/displaying-posts-depending-on-number-of-comments-and-latest-comments
http://wordpress.org/support/topic/sort-by-number-of-comments
这是我的默认代码,我的问题是,如何让此代码按评论计数排序?
<?php
/*
Template Name: Homepage
*/
get_header(); global $gp_settings, $user_ID, $user_identity, $user_level;
$referrer = $_SERVER['HTTP_REFERER'];
?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<!-- BEGIN CONTENT -->
<div id="content">
<!-- BEGIN POST CONTENT -->
<?php if($post->post_content) { ?>
<div id="post-content">
<?php the_content(__('Read More »', 'gp_lang')); ?>
</div>
<?php } ?>
<!-- END POST CONTENT -->
</div>
<!-- END CONTENT -->
<?php endwhile; endif; ?>
<?php get_footer(); ?>
这是我尝试过但没有成功的代码示例
<?php
/*
Template Name: Homepage
*/
get_header(); global $gp_settings, $user_ID, $user_identity, $user_level;
$referrer = $_SERVER['HTTP_REFERER'];
?>
<?php
$querystr = "
SELECT $wpdb->posts.*
FROM $wpdb->posts, $wpdb->postmeta
WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id
AND $wpdb->postmeta.meta_key = 'tag'
AND $wpdb->postmeta.meta_value = 'email'
AND $wpdb->posts.post_status = 'publish'
AND $wpdb->posts.post_type = 'post'
AND $wpdb->posts.post_date < NOW()
ORDER BY $wpdb->posts.post_date DESC
";
$pageposts = $wpdb->get_results($querystr, OBJECT);
?>
<?php if ($pageposts): ?>
<?php global $post; ?>
<?php foreach ($pageposts as $post): ?>
<?php setup_postdata($post); ?>
<!-- BEGIN CONTENT -->
<div id="content">
<!-- BEGIN POST CONTENT -->
<?php if($post->post_content) { ?>
<div id="post-content">
<?php the_content(__('Read More »', 'gp_lang')); ?>
</div>
<?php } ?>
<!-- END POST CONTENT -->
</div>
<!-- END CONTENT -->
<?php endforeach; ?>
<?php endif; ?>
<?php get_footer(); ?>