オンとオフの隙間でつぶやく

Web ガーデニング ハンドメイド
0 comments

人気の記事を表示するby WordPress

[sourcecode]
<ul class="popular-posts">
<?php $result = $wpdb->get_results("SELECT comment_count,ID,post_title FROM $wpdb->posts ORDER BY comment_count DESC LIMIT 0 , 5"); //5件
foreach ($result as $post) {
setup_postdata($post);
$postid = $post->ID;
$title = $post->post_title;
$commentcount = $post->comment_count;
if ($commentcount != 0) { ?>
<li>
<a href="<?php echo get_permalink($postid); ?>" title="<?php echo $title ?>">
<?php echo $title ?></a><br />
<span class="comments_number"><?php comments_number(‘0’, ‘1’, ‘%’ ); ?></span>
</li>
<?php } } ?>
</ul>

[/sourcecode]

Webデザインレシピ様

Leave A Comment