Template Syntax

With ASA2 - The Amazon Affiliate Plugin for WordPress you can create conditional templates. This means you can manipulate the placeholder contents or inlcude dynamic content, depending on the value of placeholders (see all available Placeholders).

ASA2 - The Amazon Affiliate Plugin for WordPress uses the power of the famous Twig template engine for PHP to realize conditions, loops and filters in templates. Hence you can use the default functionality of Twig.

Additionally ASA2 - The Amazon Affiliate Plugin for WordPress provides special filters and functions to optimze the usage with WordPress. You can access WordPress internal functions with {{ wp.[function_name] }}, for example {{ wp.get_post(8).post_title }} which will display the post title of the post with ID 8. This gives you a great flexibility in creating custom, dynamic templates.

Language constructs

Conditional templates have two main language constructs.

{{ placeholder }}

{{ placeholder }} is used to print the contents of the available Placeholders.

For example, to embed the product title in your template, use:

{{ Title }}

{% statement %}

{% statement %} is used to execute statements. Statements can be Conditions, Loops and Functions.

This example uses the if condition to only output the product features if the placheolder {{ FeaturesHTML }} is not empty:

{% if FeaturesHTML is not empty %}
    <p>{{ FeaturesHTML }}</p>
{% endif %}

Note

Inside a statement placeholders do not have to be embedded in {{ }}

For more details about the syntax check the following chapters: