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装置进程中遇到中文乱码的解决办法

在装置wordpress的时分,依照外面的readme.html的步骤进行装置,然而在拜访wp-admin/install.php的时分就呈...

为WordPress增加文章字数统计的办法

WordPress在后盾编辑日志时编辑框左下角有一个字数统计,不过只显示在后盾,能不能在前台也加上文章字数统计...

WordPress最好用的博客零碎之一

要害字形容:之一 零碎 博客 最好 WordPress 主题 十分 应用 不便   WordPress 是目前最好用的博客零碎之...

如何应用wordpress钩子函数在宣布文章的同时增加一条记载

我要对文章进行排序,依照投票数的多少排,曾经投票的都会记载投票数,而没有投票的文章没有记载,默许投票...

Wordpress插件的应用

要害字形容:应用 插件 Wordpress 能够 文件 需求 网站 目录 网友 Wordpress 的主题能够让你的 Wordpress ...

教你完成WordPress博客的“预加载”性能

chrome阅读器为什么比普通的阅读器快呢?缘由是chrome阅读器给全副页面都弄了预加载性能。 目前可能还是有少...

需求提交

客服服务