typecho 获取最新文章,指定数量
发现这个方法还常用的,特意分享出来。
<?php $this->widget('Widget_Contents_Post_Recent','pageSize=5')->to($news);?>
<?php if($news->have()):?>
<?php while($news->next()): ?>
<a href="<?php $news->permalink();?>">
<h2 class="card-title"><?php $news->title(); ?></h2>
</a>
<?php endwhile; ?>
<?php endif; ?>
和在使用博客的那个<?php while ($this->next()) : ?><?php endwhile; ?>
代码一样的用法,$news
和$this
一样。
'pageSize=5'
便是输出5篇最新文章,数字自己定义即可。
分类:
Typecho博客教程
标签:
typecho教程最新文章数量
版权申明
本文系作者 @木灵鱼儿 原创发布在木灵鱼儿站点。未经许可,禁止转载。
评论
最新文章
如何在项目中使用一个自定义的npm模块(如何使用一个魔改后的npm模块)
0点赞
·
1评论
Debian12 更新系统版本(目前更新至12.5版本)
0点赞
·
0评论
Nestjs CORS配置和生产环境处理
1点赞
·
0评论
Debian12 SSH连接报错:Error Handshake failed no matching host key format
0点赞
·
0评论
Prisma 使用MongoDB创建数据时报错:Prisma needs to perform transactions, which requires your MongoDB server to be run as a replica set.
0点赞
·
0评论
目录
暂无目录
暂无评论数据