中文字幕在线观看,亚洲а∨天堂久久精品9966,亚洲成a人片在线观看你懂的,亚洲av成人片无码网站,亚洲国产精品无码久久久五月天

wordpress如何調用某一個分類下的熱門文章(熱評文章)

2018-11-02    來源:學做網(wǎng)站論壇

容器云強勢上線!快速搭建集群,上萬Linux鏡像隨意使用

做網(wǎng)站過程中,如果想對自己網(wǎng)站中的文章進行排序,就可以利用熱門文章代碼來自動調用,熱門文章可以分為二種方法:按照文章瀏覽量和文章評論數(shù)。

wordpress如何調用某一個分類下的熱門文章

下面是二種方式來調用某一個分類下熱門文章的代碼。

wordpress程序調用按照瀏覽量來調用某一個分類下的熱門文章代碼:(注意使用這種方式調用熱門文章,網(wǎng)站必須安裝wordpress瀏覽量插件)

<?php if (have_posts()) : ?>
<?php query_posts('cat=5' . $mcatID. '&caller_get_posts=1&showposts=16&v_sortby=views'); ?>
<?php while (have_posts()) : the_post(); ?>
<li><a href="<?php the_permalink() ?>" title="<?php the_title() ?>"><?php the_title() ?></a></li>
<?php endwhile;?>
<?php endif; wp_reset_query(); ?>

wordpress程序調用按照評論量來調用某一個分類下的熱門文章(熱評文章)代碼:

<?php

$post_num = 10; // 設置調用條數(shù)

$args = array(

'post_password' => '',

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

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

'orderby' => 'comment_count', // 依評論數(shù)排序.

'posts_per_page' => $post_num

);

$query_posts = new WP_Query();

$query_posts->query($args);

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

<li><?php comments_number('0', '1', '%' );?> 次評論: <br><a href="<?php the_permalink() ?>" title="<?php the_title() ?>"><?php the_title() ?></a></li>

<?php } wp_reset_query();?>

相關知識:WP程序調用最新文章 相關文章 隨機文章代碼

標簽: 代碼

版權申明:本站文章部分自網(wǎng)絡,如有侵權,請聯(lián)系:west999com@outlook.com
特別注意:本站所有轉載文章言論不代表本站觀點!
本站所提供的圖片等素材,版權歸原作者所有,如需使用,請與原作者聯(lián)系。

上一篇:wordpress免插件顯示文章瀏覽量次數(shù)

下一篇:WordPress調用某個分類下文章數(shù)量的四種方法