未显示 Wordpress 树枝模板简码 [英] Wordpress twig template shortcode not displayed

查看:39
本文介绍了未显示 Wordpress 树枝模板简码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Wordpress 中使用 Symfony Twig 模板,一切正常,只是我无法在页面模板中显示任何短代码.

我正在尝试使用 Contact form 7 插件显示联系表单.

短代码类似于 [contact-form-7 id='1234' title='Contact']甚至 Wordpress 默认短代码也不起作用.

这是我的页面模板代码:

{% 扩展 'base.html.twig' %}{% 块内容 %}<h1>{{ post.post_title }}</h1><div class="entry">{{ post.post_content|raw }}

{% 结束块 %}

如果我替换

{{ post.post_content|raw }}

由此

{{ wp.do_shortcode('[contact-form-7 id="1234" title="联系人"]') }}

我可以看到联系表格.但我不想在我的模板文件中编写短代码.

感谢您的帮助

解决方案

以下之一应该有效!

<块引用>

{{ wp.do_shortcode( post.post_content) }}

或者,

<块引用>

{{ wp.do_shortcode( post.post_content)|raw }}

或 ,

<块引用>

{{ wp.do_shortcode( post.post_content|raw ) }}

<块引用>

{{ wp.do_shortcode( post.post_content|raw )|raw }}

更新

工作代码是:

<块引用>

{{ wp.do_shortcode( post.post_content)|raw }}

I'm using Symfony Twig template with Wordpress, everything runs fine except that I can't get any shortcode to be displayed in a page template.

I'm trying to display a contact form with Contact form 7 plugin.

The shortcode is something like [contact-form-7 id='1234' title='Contact'] Even Wordpress default shortcode are not working.

Here is my code for page template:

{% extends 'base.html.twig' %}

{% block content %}
    <h1>{{ post.post_title }}</h1>

    <div class="entry">
        {{ post.post_content|raw }}
    </div>
{% endblock %}

If I replace

{{ post.post_content|raw }}

by this

{{ wp.do_shortcode('[contact-form-7 id="1234" title="Contact"]') }}

I can see the contact form. But I don't want to write the shortcode in my template file.

Thanks for your help

解决方案

One of the following should work!

{{ wp.do_shortcode( post.post_content) }}

or,

{{ wp.do_shortcode( post.post_content)|raw }}

or ,

{{ wp.do_shortcode( post.post_content|raw ) }}

or

{{ wp.do_shortcode( post.post_content|raw )|raw }}

Updated

Working Code Is :

{{ wp.do_shortcode( post.post_content)|raw }}

这篇关于未显示 Wordpress 树枝模板简码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆