Saltar navegación

[Resuelto] Trim post title

This support ticket is created hace 4 semanas. 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)

Este tema contiene 1 respuesta, tiene 1 mensaje.

Última actualización por Timothy hace 3 semanas, 6 días.

Asistido por: Minesh.

Autor
Mensajes
#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
Colaborador

Idiomas: Inglés (English )

Zona horaria: 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:
- enlace oculto

#2806813

Thanks!