微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

尝试从 .twig 文件加载 WP 插件简码

如何解决尝试从 .twig 文件加载 WP 插件简码

我尝试在 a related thread 上提出这个问题,但它在没有任何通知的情况下被删除了(我知道我没有提供解决方案,但提醒您删除我的帖子会有所帮助。 。我是新来的)。我在这里重试:

我以前从未使用过 Timber,并且拥有带有生成的短代码“[sp_easyaccordion id="352"]”的 Easy Accordion Pro 插件,并在我的 .twig 模板文件(位于 Themes>My Theme 中)中尝试了以下内容>templates) 并且所有呈现的都是纯文本 [sp_easyaccordion id="352"]。有什么想法吗?

{% function('do_shortcode','[sp_easyaccordion id="352"]') %}

{{ function('do_shortcode','[sp_easyaccordion id="352"]') }}

{% filter shortcodes %}
{{ wp.do_shortcode('[sp_easyaccordion id="352"]') }}
{% endfilter %}

{{ wp.do_shortcode('[sp_easyaccordion id="352"]') }}

简单地

{% filter shortcodes %} [sp_easyaccordion id="352"] {% endfilter %}

这些都没有用。另请注意,我没有在我的 function.PHP 文件添加任何内容......这是我遗漏的东西吗?

解决方法

根据 documentation 应该是:

{% filter shortcodes %}
    [sp_easyaccordion id="352"]
{% endfilter %}

否则你也应该能够调用这样的函数:

{{ function('do_shortcode','[sp_easyaccordion id="352"]') }}

https://timber.github.io/docs/guides/functions/#function

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。