A5下载 - 努力做内容最丰富最安全的下载站!

A5站长下载站

当前位置:A5下载 > 源码技巧 > wordpress > WordPress调用指定分类下的文章

WordPress调用指定分类下的文章

时间:2015-09-07 13:42作者:fang人气:63

<ul>

<?php

$args=array(

'cat' => 1, // 分类ID

'posts_per_page' => 10, // 显示篇数

);

query_posts($args);

if(have_posts()) : while (have_posts()) : the_post();

?>

<li>

<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> //标题

<span>

<?php if (has_excerpt()) {

echo $description = get_the_excerpt(); //文章编辑中的摘要

}else {

echo mb_strimwidth(strip_tags(apply_filters('the_content', $post->post_content)), 0, 170,"……"); //文章编辑中若无摘要,自定截取文章内容字数做为摘要

} ?>

</span>

</li>

<?php endwhile; endif; wp_reset_query(); ?>

</ul>

标签WordPress,调用,指定,分类,文章,php,args

相关下载

查看所有评论+

网友评论

网友
您的评论需要经过审核才能显示

热门阅览

最新排行

公众号