wordpress調用全站熱門文章代碼

<?php

$post_num = 10; // 顯示篇數

$args = array(

‘post_password’ => ”,

‘post_status’ => ‘publish’, // 只選公開的文章.

‘post__not_in’ => array($post->ID),//排除當前文章

‘caller_get_posts’ => 1, // 排除置頂文章.

‘orderby’ => ‘comment_count’, // 依評論數排序.

‘posts_per_page’ => $post_num

);

$query_posts = new WP_Query();

$query_posts->query($args);

while( $query_posts->have_posts() ) { $query_posts->the_post(); ?>

<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>

<?php } wp_reset_query();?>