Noob17 Noob17 - 8 months ago 92
PHP Question

How do I write the wordpress function "is_front_page()" in twig Timber code?

My goal is to simply output something only on the index page of my wordpress using Twig code. I have set a static page called Home.

I have tried this in my base.twig:

{% if is_front_page %}
Homepage content
{% endif %}

But this doesn't do anything and I just find can't easily find it for some reason.

Any help is appreciated! Thanks in advance


Timber comes with the fn (also has alias of function) that let's you execute external PHP functions. So something like this would work:

{% if fn('is_front_page') %}
  Homepage content
{% endif %}