How-to: Shorten product title and description

Written by Timo

Creator of ASA2

February 12, 2016

A frequently requested feature is to shorten an Amazon product’s title or description text because the original content is so long that it would destroy the page layout. This is possible with ASA 2’s powerful template syntax. You can use the template filters to customize placeholders in many different ways. To shorten a text, we can use the slice filter. With it you can extract a slice of a string.

Shorten Product Title …

To shorten the product title and be sure it will never have a length of more than 60 characters, we can use this placeholder syntax:

{{ Title|length > 60 ? Title|slice(0, 60) ~ '...' : Title }}

The code checks if the product title is longer than 60 characters. If so, it cuts the title after 60 characters and appends three dots. If the title is shorter, just the original title will be displayed. This placeholder syntax is used in the following template:
[asa2 tplid="12" country_code="US"]B00OQVZDJM[/asa2]
… and Description

The same procedure works for the product description text, which is represented by placeholder {{ EditorialReviewsContent }}. This placeholder syntax will limit the description text to a maximum of 250 characters:

{{ EditorialReviewsContent|length > 250 ? EditorialReviewsContent|slice(0, 250) ~ '...' : EditorialReviewsContent }}

This placeholder syntax is used in the following template where you can see a shortened product description:

Search and replace parts of texts

When it comes to the modification of texts, another very useful filter is replace. It can be used like a search and replace tool. Let’s say you have a list of blu-ray movies and they all have “[Blu-ray]” in their titles. To get rid of that and just show the movie title, you can use the replace filter like so:
{{ Title|replace({'[Blu-ray]': ''}) }}

Permanent Custom Title

There is another option to customize a product’s title permanently. You can change the title of any ASA 2 Repo item like you would with any other WordPress post. Just open the edit page of a Repo item, change the title and click the “Update” button. From now on the new title will be used for placeholder {{ Title }}.

Changing ASA 2 Repo item title

You May Also Like…


  1. Ataul Ghani

    I love this plugin. I’ve share a review for amazon affiliate plugin for WordPress but didn’t added this one. Can i feature this plugin to my post? Please let me know. Thank You!

  2. Paula

    Where do you actually place the code in order to shorten the title? I want to use the Carousel option but the title is too long for each of the products. I have no idea how to shorten the title without knowing where to actually place the code you have indicated above.

    • Timo

      Hi Paula,

      thank you for your feedback.

      The examples in this article are intended for creating your own templates. The values in the curly braces are placeholders for ASA2 templates.
      If you use the standard template, please try to include the option “title_length” in the shortcode, e.g. like this:

      `[asa2_smart_collection cat_slug=”coffee-maker” limit=”10″ title_length=”50″ tpl=”Carousel” /]`

      If 50 characters are still too many, you can of course reduce them.
      I hope this helps you. If not, you are welcome to create a ticket ( and I’ll take a look for myself.

      • Paula

        Awesome. The shortcode is all I needed. It works beautifully.

        • Timo

          Cool! Thanks for letting me know.

Submit a Comment