wp-postviews插件提供調(diào)取了熱門(mén)文章的函數(shù)和小工具,非常方便,美中不足的是熱門(mén)文章的顯示樣式只是簡(jiǎn)單的文章標(biāo)題列表,略顯單薄。
wp-postviews的把文章瀏覽數(shù)量寫(xiě)入到了一個(gè)自定義字段中,明白了這個(gè),我們就可以使用WordPress自定義查詢(xún)調(diào)用熱門(mén)文章。
<ul class="post-list">
<?php
$args = array(
'meta_key' => 'views',
'orderby' => 'meta_value_num',
'order' => 'ASC'
);
$query = new WP_Query( $args );
?>
<li>
<div class="icon-overlay"> <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('tiny'); ?></a> </div>
<div class="meta">
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
<em><?php echo get_post_meta( get_the_ID(), 'views', true ); ?></em> </div>
</li>
</ul>
查詢(xún)出來(lái)的結(jié)果是標(biāo)準(zhǔn)的WordPress查詢(xún),中間的模板可以隨便修改,可以加入圖片,調(diào)用自定義字段等等。


