Site logo

Archived topic

Limit number of words in posts when query specific tag/category

3 replies · Started by Joyce on February 13, 2021

Viewing posts 1–4 of 4

Hi there,

you can use a filter like this:

add_filter( 'excerpt_length', function( $length ) {
    $categories = array(
        'cat-one',
        'cat-two',
        'cat-three',
    );
    $tags = array(
        'tag-one',
        'tag-two',
        'tag-three',
    );

    if ( is_category( $categories )  || is_tag( $tags ) ) {
        $length = 25;
    }

    return $length;
}, 200 );

thanks David

You're welcome

This archived topic is closed to new replies.