> For the complete documentation index, see [llms.txt](https://wplake.gitbook.io/advanced-views/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wplake.gitbook.io/advanced-views/features/smart-templates/twig-templates.md).

# Smart Twig templates

In Advanced Views, *Layout* and *Post Selection* templates support [Twig](https://twig.symfony.com/) as a template engine.

If you're new to Twig, read our [Twig features review](/advanced-views/features/smart-templates/twig-templates/features.md).

## 1. Functions by Advanced Views

We extended Twig to include additional WordPress-related functions, in addition to its built-in functions. You can find these extended functions listed below.

<pre class="language-twig"><code class="lang-twig">{{ print_r(my_array) }}
{# calls the built-in PHP print_r function (displays the array for debug purposes) #}

{{ wp_interactivity_state('name', {stateArg:'some'}) }}
{# calls the built-in WordPress wp_interactivity_state function #}

<strong>{{ wp_interactivity_data_wp_context({contextArg:'some'}) }}
</strong>{# calls the built-in WordPress wp_interactivity_data_wp_context function #}

{{ paginate_links({total:'10',}) }}
{# calls the built-in WordPress paginate_links function #}
</code></pre>

You'll use the interactivity functions in *Layouts* when employing the [WP Interactivity API](/advanced-views/layouts/component-options/interactivity-api.md), while `paginate_links` is used inside *Post Selections* when the 'Source: Page content' option is chosen.

```twig
{{ _query_argument('my-category-id') }} 
{# retrieves the argument from the current page URL ($_GET in PHP) #}

{{ _is_user_with_role("role") }} 
{# checks if user has the specified role. 
You can pass user id as the second argument, or it'll use the current user id #}

{{ _is_user_logged_in() }} 
{# calls is_user_logged_in() from WP #}

{{ _site_url("/my-page") }} 
{# calls site_url() from WP #}

{{ _home_url() }} 
{# calls home_url() from WP #}

{{ __("Some label") }} 
{# translates the label. 
You can pass the text domain as the second argument, 
or it'll use the "Text Domain" of your theme 
(declared in the headings of the style.css file of your theme) #}
```

## 2. Filters by Advanced Views

```twig
{{ "Some label"|translate }} 
{# translates the label (alternative to the '__' function described above)
You can pass the text domain as the second argument, 
or it'll use the "Text Domain" of your theme 
(declared in the headings of the style.css file of your theme) #}
```

## 3. Customization

You can also add your own Twig functions and filters.  Check [this hooks guide](broken://pages/17mz5ByUlebQDwXg78tS#custom-twig-functions-pro) to learn more.

## 3. Twig version

Currently, Advanced Views uses version `3.7.1` of the Twig engine.
