Skip Navigation

[Resolved] Trim post title

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
- 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 1 reply, has 1 voice.

Last updated by Timothy 2 days, 14 hours ago.

Assisted by: Minesh.

Author
Posts
#2806666

Is there a way to trim the post title, or post title link ([wpv-post-link]), to like 8 words in the legacy view loop editor?

Thanks,

tim

#2806690

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

There is no native way but either you can add the custom shortcode to shorten your post title by using custom shortcode.

For example - To limit the output from any field to a certain number of words, you can register a custom shortcode:

function word_trim_custom_func( $atts, $content = null ) {
    $args = shortcode_atts( array(
        'words' => '8',
        'title'=>'',    
    ), $atts );
 
    return wp_trim_words($args['title'], $args['words'] );
}
add_shortcode( 'word_trim_custom', 'word_trim_custom_func' );

The above code snippet can be included through either Toolset's "Custom Code" section:
=> https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/

After that, you can call the above shortcode as:

[word_trim_custom words="8" title="[wpv-post-title]"]

Alternatively - you can check the following Doc:
- hidden link

#2806813

Thanks!