问题
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