2014-03-31 42 views
0

,一切都運行只是我不能顯示在一個頁面模板的任何短碼的罰款。WordPress的樹枝模板簡碼

我試圖顯示與聯繫表7插件聯繫表單。

短代碼就像[contact-form-7 id='1234' title='Contact'] 即使WordPress的默認短代碼不起作用。

這裏是我的網頁模板代碼:

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

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

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

如果我更換

{{ post.post_content|raw }} 

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

可以看我的聯繫表格。但我不想在我的模板文件中編寫簡碼。

感謝您的幫助

回答

1

以下其中一項應該可以工作!

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

,或者

{{wp.do_shortcode(post.post_content)|原料}}

或者,

{{wp.do_shortcode(post.post_content |原料)}}

{{wp.do_shortcode(post.post_content |原料)|生}}

更新

工作代碼爲:

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

+0

這是工作: {{wp.do_shortcode(發佈。post_content)| raw}} 我也嘗試在帖子內容中添加額外的html,它的渲染效果很好:) – user3480375

1

試試這個

{{ post.post_content|shortcodes }} 

而且具有自定義字段

{{ customfield|shortcodes }}