标签: wordpress timber
我想返回最后10篇帖子的列表,其中只包含标题和永久链接。
在木材中实现这一目标的最佳方法是什么?
答案 0 :(得分:0)
如果不知道您要定位哪个页面,很难提供明确的内容。但假设它是默认的" WordPress查询"最后10个帖子会自动进入主页,所以在Twig你只需要这样做:
{% for post in posts %} <h2><a href="{{ post.link }}">{{ post.title }}</a></h2> {% endfor %}