Skip Navigation

[Gelöst] create excerpt from custom field

This support ticket is created vor 8 Jahre. 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 4 Antworten, has 2 Stimmen.

Last updated by Marisa vor 8 Jahre.

Assisted by: Minesh.


Need the copy and paste code to

A. shorten a custom field text to a specified amount of characters
B. Create a custom excerpt that applies to a custom field (not to the default content editor).

on the output of the custom field using Views.

I've read about half a dozen help tickets but they are not exactly what I'm trying to do , or the one that looked like it was didn't work.



Languages: Englisch (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Could you please try to add following custom shortcode to your current theme's functions.php file.

add_shortcode('limit_content', 'trim_shortcode');
 function trim_shortcode($atts, $content = '') {
    $content = wpv_do_shortcode($content);
    $length = (int)$atts['length'];
    if (strlen($content) > $length) {
        $content = substr($content, 0, $length) . '…';
    // Strip HTML Tags
    $content = strip_tags($content);
    return $content;

And you can call it using your custom field. For example:

[limit_content length="140"][types field="your-field" output="raw"][/types][/limit_content]

I hope this will be exactly what you are looking for. If you still have any issues with above code, please do not hesitate to get in touch with me.


Very similar to another support ticket I tried to follow. With the same results. See screenshot.


Never mind - it works. I had something wrong in the function before, and this time I think I hadn't uploaded it to the server.

<div class="slide-container">  <div class="slide-image" style=" background-image:url('[types field="case-story-image" size="full" url="true"][/types]');"></div>
  <a href="[wpv-post-slug]"><div class="slide-caption"><h2 class="case-story">[limit_content length="15"][wpv-post-title][/limit_content]</h2><div class="caption-copy">[limit_content length="150"][types field="case-story-text" output="raw"][/types][/limit_content]</br><span style="display:inline-block; text-align:right; color:#fff; float:right; text-decoration:underline;">read more</span>
  <a href="[wpv-post-slug]">
    <h2 class="case-story mobile-caption">[wpv-post-link]</h2></a>

and looks like this. If there is any way to recognize and not break a word easily, let me know. Otherwise, we're good.

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.