Easy Way to trim Excerpt by Words or Charakters


Hey,

i search to a way to trim beans excerpt custom. Is the default excerpt trimmed by charakters or words?

Special Thanks Marcus


You can trim the excerpt by words using wp_trim_words(). For example...

add_filter( 'get_the_excerpt', 'trim_excerpt' );

function trim_excerpt( $excerpt ) {

        // trims by 40 words, adds "..." at the end if excerpt larger than 40 words
        $trim_excerpt = wp_trim_words( $excerpt, 40, '...' );
        return $trim_excerpt;

}

This is a native WordPress solution. I don't know if Beans has a way to do this.


If you want to replace the read more text you can use this code

// Modify read more text
add_filter( 'beans_post_more_link_text_output', 'example_modify_read_more' );

function example_modify_read_more() {

   return 'your read more text';

}

Write a reply

Login or register to write a reply, it's free!