WordPress无插件调用**、抢手、随机文章实例代码

调用**文章:
 
<ul>
<?php $post_query = new WP_Query(‘showposts=10′);
while ($post_query->have_posts()) : $post_query->the_post();
$do_not_duplicate = $post->ID; ?>
<li><a href=”<?php the_permalink(); ?>”><?php the_title(); ?></a></li>
<?php endwhile;?>
</ul>

调用抢手文章:
 
<ul>
<?php
$post_num = 10; // 设置调用条数
$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(); ?>
<li><a href=”<?php the_permalink(); ?>” title=”<?php the_title(); ?>”><?php the_title(); ?></a></li>
<?php } wp_reset_query();?>
</ul>

调用随机文章:
 
<ul>
<?php
global $post;
$postid = $post->ID;
$args = array( ‘orderby’ => ‘rand’, ‘post__not_in’ => array($post->ID), ‘showposts’ => 10);
$query_posts = new WP_Query();
$query_posts->query($args);
?>
<?php while ($query_posts->have_posts()) : $query_posts->the_post(); ?>
<li><a href=”<?php the_permalink(); ?>” rel=”bookmark” title=”<?php the_title_attribute(); ?>”><?php the_title(); ?></a></li>
<?php endwhile; ?>
</ul>

以上就是安达网络工作室关于《WordPress无插件调用**、热门、随机文章实例代码》的一些看法。更多内容请查看本栏目更多内容!

版权声明:本文为 安达网络工作室 转载文章,如有侵权请联系我们及时删除。
相关文章
Wordpress改换主题之后出错的处理办法

明天吃完午饭,劳动劳动,最近搞了一下google adsense,不过最终的审核没经过,我想会不会是界面不难看呢,...

wordpress自带的缓存性能应用引见

用动态化当然能够处理这些成绩,不过关于流量不大的博客就没必要了。 wordpress自带有缓存体系,要害的函数...

wordpress 优化指南

但惋惜的是,目前wordpress主题中95%以上是本国人写的,其设计是基于东方文字的,中国的blogger将这些主题拿...

WordPress 避免歹意评论的办法

即便你的博客治理后盾的治理员身份被人破解了,普通他也不会同时破解你的网站空间ftp账号,所以他也更改不了...

wordpress调用以后分类下子分类的办法

本文实例讲述了wordpress调用以后分类下子分类的办法。分享给大家供大家参考。详细剖析如下: 本人没用过wo...

编写PHP脚本肃清WordPress头部冗余代码的办法解说

wordpress头部的代码十分多,包括WordPress版本,前后文、第一篇文章、主页meta信息等各种冗余代码,这些对...

需求提交

客服服务