【发布时间】:2018-03-17 13:33:54
【问题描述】:
Timber 中有这个功能
{{post}}
你从哪里得到类似的东西
{{post.post_title}}
但WordPress中还有其他功能,例如
get_the_permalink();
不能从 post.get_the_permalink 或 post.get_permalink 访问
这些是我可以访问的变量
- 身份证
- post_author
- post_date
- post_date_gmt
- post_content
- post_title
- post_excerpt
- post_status
- comment_status
- ping_status
- post_password
- post_name
- to_ping
- 已ping通
- post_modified
- post_modified_gmt
- post_content_filtered
- post_parent
- 指导
- menu_order
- post_type
- post_mime_type
- comment_count
- 过滤器
正如这个 Timber 文档描述的那样,有一些动作 [Timber Doc] 但你必须在 functions.php 文件中定义每个函数......这意味着我必须从 php 创建每个已经存在的函数并将其“重定向”到wordpress 功能。然后将其绑定到 Twig。
还有一种方法,你可以看到 here 现在是 deprecated
【问题讨论】:
标签: php wordpress twig timber twig-extension