Target a specific page template with Timber (WordPress)

霸气de小男生 提交于 2021-02-17 03:19:32

问题


I am trying to output some HTML content on a specific page with a Timber file (.twig). I have been able to output content on the home page but not on a specific page.

I tried the following code :

% if fn (is_page('proprietes')) %}
    <h5 class="widget__headline">Test</h5>
    {% endif %}

But I end up with a blank page. I probably made a dump syntax mistake...

Thanks for your help.


回答1:


Correct way:

{% if fn('is_page', page) %}

"page" can be slug/id/array of id's etc.




回答2:


Try using id instead of slug, eg:

{% if fn (is_page(7)) %}
    <h5 class="widget__headline">Test</h5>
{% endif %}


来源:https://stackoverflow.com/questions/41706400/target-a-specific-page-template-with-timber-wordpress

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!