Navigation überspringen

[Gelöst] Trim post title

This support ticket is created vor 1 Monat. 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
- 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)

Dieses Thema enthält 1 Antwort, hat 1 Stimme.

Zuletzt aktualisiert von Timothy vor 4 Wochen, 1 Tag.

Assistiert von: Minesh.

Author
Artikel
#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
Unterstützer

Sprachen: Englisch (English )

Zeitzone: 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:
- versteckter Link

#2806813

Thanks!