wordpress教程
WordPress调用指定分类下的文章
wordpress教程
51源码
2022-11-11
共人阅读
<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>
版权声明:文章搜集于网络,如有侵权请联系本站,转载请说明出处:https://www.51yma.cn/jiaocheng/wordpress/533.html
文章来源:
热门推荐
-
01WordPress引用加载PHP模板方法 855
-
02选WordPress主机空间看这3点 806
-
03利用宝塔面板优化WordPress缓存 805
-
04新手利用WordPress建站详细步骤分享 745
-
05WordPress只搜索标题 726