wordpress如何無插件調用最新、熱門、隨機文章?
WordPress無插件調用最新、熱門、隨機文章實例代碼
推薦:《wordpress教程》
WordPress無插件調用最新、熱門、隨機文章,具體實現代碼如下,感興趣的朋友可以參考下哈,希望對大家在新聞調用上有所幫助
??
調用最新文章:?
代碼如下:
- ? have_posts())?:?$post_query->the_post();? $do_not_duplicate?=?$post->ID;??>?
- ”>
? ?
調用熱門文章:?
代碼如下:
- ? ?”,? ‘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();??>?
- ”?title=””>
? ?
調用隨機文章:?
代碼如下:
- ? ID;? $args?=?array(?‘orderby’?=>?‘rand’,?‘post__not_in’?=>?array($post->ID),?‘showposts’?=>?10);? $query_posts?=?new?WP_Query();? $query_posts->query($args);? ?>? have_posts())?:?$query_posts->the_post();??>?
- ”?rel=”bookmark”?title=””>
? ?
? 版權聲明
文章版權歸作者所有,未經允許請勿轉載。
THE END