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 Team,
I'd like to restrict number of words in post when I see the post list for specific tag/category
e.g. http://www.abc.com/tag/tag1, http://www.abc.com/category/catatory1
thanks,
Joyce
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.