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主动将半角转换为全角 制止全角和半角的转换

找到wp-includes/formatting.php文件中复制代码代码如下:// This is not a tag, nor is the texturization ...

WordPress简略三步完成首页文章显示缩略图(无插件)

喜爱折腾修正Wordpress主题的冤家,一定遇到过这样的成绩,想在首页文章中显示缩略图,有插件能够完成,不过...

wordpress去掉自带的logo或许左侧栏的菜双方法

去掉logo或许左侧栏的菜单,避免被改掉。 在应用模板下的functions.php下修正 复制代码代码如下: function ...

修正wordpress上传暂时目录处理wordpress无奈装置插件包的办法

处理办法这是由于空间中的&rsquo;C:\WINDOWS\TEMP&rsquo;目录没有设置IIS拜访权限,需求空间商为你设置目录...

WordPress 完成文章评论排行榜

用到了WordPress性能函数Query_post()的一种初级用法,就是获取本周或当月或最近30天评论最多的肯定数量的日...

解说WordPress中用于获取评论模板和搜寻表单的PHP函数

comments_template()(获取评论模板) comments_template() 函数用来获取评论模板,普通只能用在文章或许页...

需求提交

客服服务

亿鸽在线客服系统