Site logo

Archived topic

Excerpt limit to be character count instead of word count

3 replies · Started by Patricia on March 23, 2021

Viewing posts 1–4 of 4

Hi there support,

Currently we have setup the blog roll and with the use of WP Show Posts plugin. It was set to limit per word but the problem is, some words are lengthy.
I am wondering how can I change the except limit from word count to character/letter count? The word count sometimes messes up with the height of the boxes and we wanted it to be the same height and aligned.

https://newsite.antiagingninjas.com/blog/ https://prnt.sc/10tfosg

thanks in advance for your help :)

Hi there,

changing from word to character count is tricky - instead try adding this CSS:

.wp-show-posts-columns#wpsp-19426 .wp-show-posts-inner {
  display: flex;
  flex-direction: column;
}

.wpsp-read-more {
  margin-top: auto;
}

It should align all Read More buttons.

Hi David,

thanks for your reply.

thanks i will try this out.

but just in case we really need to change it to word count, how can we do that.

I know a bit of PHP so I think it's worth the try. thankyou :)

You can try this snippet:

add_filter( 'the_excerpt', function( $excerpt ) {
  $excerpt = substr( $excerpt, 0, 60 );

  return $excerpt;
} );

change the 60 to the number of characters you want displayed.

This archived topic is closed to new replies.