Wordpress无插件调用最新、热门、随机文章实例代码
WORDPRESS无插件调用最新、热门、随机文章,具体实现代码如下,感兴趣的朋友可以参考下哈,希望对大家在新闻调用上有所帮助
调用最新文章:
代码如下:
登录后复制 登录后复制 登录后复制调用热门文章:
代码如下:
登录后复制 登录后复制 登录后复制-
”, ‘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=” ”>