26th Sep '25
/
0 comments

Bricks Dynamic Data Tag for Text-type Custom Field Value with Word Limit

Updated on 29 Sep 2025

In the Bricks Discord chat, a user asks:

Got a quick question about limiting dynamic data - post_excerpt:55 – Limit post excerpt to 55 words. I like that it automatically puts a "..." at the end when the excerpt is longer. I want the same for other dynamic data such as {my_custom_description:55} but it only limits the words and doesnt put "..." at the end when its longer. How to achive that?

This Pro tutorial provides the code that registers a custom_field_word_limit_fieldname:number dynamic data tag to output the specified text-type field's text - truncated to the specified number of words (if the word limit is specified) with ellipsis (...) at the end.

For example, let's say you've used ACF and created a field named page_description.

custom_field_word_limit_page_description:22 enclosed in curly braces will render the page_description field's value limited to the first 22 words with ... at the end (if the text has more than 22 words).

When the word limit number is omitted, the entire field value will be shown.

This works (or at least, should in theory - let us know in the comments if it doesn't) regardless of which custom fields plugin (if one is used) is being used - ACF or Meta Box or JetEngine etc.

Add the following in child theme's functions.php (w/o the opening PHP tag) or a code snippets plugin:

This is a BricksLabs Pro tutorial.

For full access login below or create your BricksLabs Pro account

Get access to all 630 Bricks code tutorials with BricksLabs Pro

Related Tutorials..

Pro
ACF Relationship Select Filter in Bricks

ACF Relationship Select Filter in Bricks

In the BricksLabs Facebook group, a user asks: I'm learning about ACF relationships and attempting to output a list of posts on any given page,…
Categories:
Pro
Meta Box Relationship in Bricks using Posts Query Loop

Meta Box Relationship in Bricks using Posts Query Loop

This Pro tutorial is similar to the recent ACF Relationship in Bricks using Posts Query Loop guide but for Meta Box. In the past, we…
Categories:
Pro
Conditional Rendering Based on Current Date and Time in Bricks when Using Meta Box

Conditional Rendering Based on Current Date and Time in Bricks when Using Meta Box

A Pro member of our site asks: Using bricks + Meta, conditionally show a post listing under 3 different conditions, based on the Current Date…
Pro
ACF Relationship: Show all other events related to the artists of the current event

ACF Relationship: Show all other events related to the artists of the current event

How all other events related to the artists of the current event can be output in a Bricks query loop.
Categories:
Custom Function for ACF Link Field

Custom Function for ACF Link Field

How to output the label of an ACF link field through Dynamic Data.
Categories:
Tags:
Pro
ACF User Field Bricks PHP Query

ACF User Field Bricks PHP Query

In the Bricks Facebook group a user asks: my end goal was to create a set of cards that would display the Users that are…
Categories: