0
我已經嘗試了以下鏈接上的解決方案,但是,我可以不讓他們顯示帖子!WordPress的,排序帖子按評論計數
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(); ?>
請記住,'comment_count'參數僅適用於Wordpress 2.9或更高版本。 – maiorano84 2013-02-16 05:00:37
我使用的是一個名爲buddy的好友新聞主題,顯示附加到帖子的圖像縮略圖,您的示例只返回評論,我將如何去查找好友主題正在使用的修改後的查詢,以便我可以使用該查詢並添加comment_count按順序排列? – 2013-02-17 01:23:20