Twig Anything – Templates Reference

You have total control of how JSON or MySQL data is displayed.

You do control by creating a Twig Template that looks like this (click to enlarge):

What is twig template

A Twig Template is simply HTML with Twig syntax enabled, with no limitations! We use the original Twig library to process templates, which means you have access to the full power of Twig syntax, including loops, if/else statements, array filters, string transformation and much more.

Additionally, Twig Anything makes some more WordPress data available in your templates and even in the MySQL queries you configure to fetch data from your blog’s database.

Full list of available variables and functions in Twig Templates

WordPress globals

To access, prefix the global name with wp_globals. (with dot). For example: {{wp_globals.post.ID}}

See the full list in WordPress documentation.

WordPress conditionals

For example: {{ is_front_page() }} - see the full list of the conditional functions.

Standard WordPress functions

  • {{ get_the_ID() }} – retrieves the numeric ID of the current post (docs).
  • {{ get_current_blog_id() }} – retrieves the current blog ID (docs)
  • {{ wp_get_current_user() }} – retrieves the current user object – WP_User (docs)

Non-standard functions

  • {{ get_current_user_meta() }} – retrieves a single meta field of the current user; works the same as the standard ger_user_meta() function, but does not have $user_id as its first parameter.

All Twig language features

Full power of the Twig syntax is available. Learn from the Twig Reference.


 

See some wonderful demos or download Twig Anything.