Feature Request - Add Length Parameter to DC

Hi Charlie,

I have a feature request for you. On a CPT for both singular and archive layouts, I exclusively use ACF Pro fields for the content. When creating a grid of, for example, Projects on the archive layout I want to bring through the ACF field called introduction. The content is a few short paragraphs on the single layout, but when using this on the projects grid, the entire field content is rendered.

Currently, I understand length="30" is only available to an Excerpt DC. Is there a way to add it to other fields, apart from the Excerpt. For example:

{{dc:acf:post_field field="introduction" length="30"}}

Many thanks,
Christopher

1 Like

If you enable Twig you can utilize the u filters. Make sure String Extra is enabled in the Twig section.

In your case it would be.

{{ acf.post_field({"field":"introduction"}) | u.truncate(30) }}

Have a great day.

1 Like

Thank you very much Charlie - perfect!

However, that truncates by characters. Your example helped me find the method to do it by words (25 words in this case): {{ acf.post_field({"field":"introduction"}) | split(' ') | slice(0, 25) | join(' ') }}

Have a great weekend,
Christopher

2 Likes