您的位置:首页 > 其它

wordpress调用最新、热门、随机文章

2013-11-25 16:40 260 查看
调用最新文章:

省略

” href=””>
调用热门文章:

$post_num = 14; // 设置调用条数

$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(); ?>

” title=””>
调用随机文章

global $post;

$postid = $post->ID;

$args = array( ‘orderby’ => ‘rand’, ‘post__not_in’ => array($post->ID), ‘showposts’ => 14);

$query_posts = new WP_Query();

$query_posts->query($args);

?>

have_posts()) : $query_posts->the_post(); ?>

” title=””>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: