Thierry Ouellet
Thierry Ouellet

Reputation: 11

Target a specific page template with Timber (WordPress)

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.

Upvotes: 1

Views: 4733

Answers (2)

Seba
Seba

Reputation: 21

Correct way:

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

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

Upvotes: 2

mariobros
mariobros

Reputation: 899

Try using id instead of slug, eg:

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

Upvotes: 0

Related Questions