Products Advanced

Categories and Tags

Like you know it from standard WordPress posts, you can use categories and tags with products.

In this example, the Jedi Interceptor is settled in the LEGO category “Star Wars” and I tagged it with “spaceship” and “yellow”.

ASA2 product categories and tags

Now you can use ASA2’s shortcode [asa2_smart_collection] to dynamically embed products on your pages based on categories and tags.

For example, if you want to embed three products from the category “Star Wars” tagged with “spaceship”, you could use the following shortcode:

[asa2_smart_collection cat_slug="starwars" tag="spaceship" limit="3"]

You want to show 10 “yellow” tagged items in a random order? Use this shortcode:

[asa2_smart_collection tag="yellow" limit="10" orderby="random"]

Shortcode [asa2_smart_collection]

The shortcode [asa2_smart_collection] is one of the most powerful features of ASA2. With it you can create dynamic queries to your Products section with filters for many relevant product properties.

For example, to display only Star Wars spaceships having a better average rating than 4, use this shortcode:

[asa2_smart_collection cat_slug="starwars" tag="spaceship" rating_gt="4"]

You can also add a price filter. This example would only display products with a main price lower than 100.

[asa2_smart_collection cat_slug="starwars" tag="spaceship" rating_gt="4" main_price_lt="100"]

Check the shortcode page [asa2_smart_collection] for a detailed list of all available options.

Custom Fields

Another powerful feature is the use of Custom Fields with your products.

On I have setup Custom Fields for my personal rating and my recommendation on a product. The easiest way to create these, is with the plugin Advanced Custom Fields (ACF). When you setup a new field group for products in ACF, just set the rule to “Post Type - is equal to - asa2_repo”:


Due to backward compatibility, the post type is still called “asa2_repo” because the Products section was called “Repo” in previous versions.

ASA 2 product ACF location

Then I setup the rating field with field type “Number”, field name “my_rating”, minimum value “1” and maximum value “10”, like shown in this screenshot:

ASA 2 product ACF field

The second field “recommendation” I setup with field type “Radio Button” and three choices you can see in this screenshot:

ASA 2 product ACF field

When I enter the edit page of a product item it looks like this:

ASA 2 product ACF field

I can enter a personal rating from 1 to 10 and check the radion button “Yes” if I would recommend the product. This data can then be used in ASA2 templates.

In your templates you can use all custom fields with this special placeholder:

{{ repo_custom_field_* }}


Due to backward compatibility, the placeholders are still called “repo_*”, because the Products section was called “Repo” in previous versions.

You just have to replace the “*” with the name of your custom field, like for this example to retrieve the value of custom field “my_rating”:

{{ repo_custom_field_my_rating }}


Learn more about all available ASA2 Placeholders.

Now, to display my personal rating only if I have set a value, I use this template code:

{% if repo_custom_field_my_rating is not empty %}<p>My personal rating: {{ repo_custom_field_my_rating }}</p>{% endif %}

And to show if I recommend a product:

{% if repo_custom_field_recommendation == "yes" %}<p>I recommend this product!</p>{% endif %}


Learn more about ASA2’s Template Syntax.

Of course I could display anything instead of just text, for instance load an image with my custom rating stars or a recommendation badge etc. This is just a demonstration of what is possible with custom fields on products and ASA2’s conditional template syntax.