WordPress如何无插件调用最新、热门、随机文章-WordPress

资源魔 58 0

WordPress若何无插件挪用最新、抢手、随机文章?

WordPress无插件挪用最新、抢手、随机文章实例代码

保举:《wordpress教程

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’ => ‘co妹妹ent_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教程 wordpress自学 wordpress技术

抱歉,评论功能暂时关闭!