Skip Navigation

[Resolved] Word Count Limit on Custom Field in View

This support ticket is created 5 years, 9 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 1 reply, has 2 voices.

Last updated by Christian Cox 5 years, 9 months ago.

Assisted by: Christian Cox.

Author
Posts
#1266781

I am attempting to limit the word count on a custom field pulling through to the view.

In this instance, I have an 'Event' custom post type with an 'Event Description' custom field. I want this to display on the listing page in the view, but limit it to 30 words. Is this possible?

Many thanks in advance.

#1266863

No, there's nothing exactly like this built-in to Toolset and it's not trivial to implement. The problem is when HTML is allowed in the content of the field, it's difficult to know where words begin and end. You have to account for markup and tags, and the nuances of all that are quite difficult to code effectively. One way you can try to get around this is to use CSS text-overflow and ellipsis properties. It won't limit by word count, but it can limit by physical dimensions.
https://css-tricks.com/snippets/css/truncate-string-with-ellipsis/