Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Change post exceprt moodule to 50 word
- * This code will work to Module that have 191 Excerpt Length value
- */
- function custom_trim_by_character( $excerpt, $post_id, $length, $excerpt_more ) {
- if ( 191 !== $length ) {
- return $excerpt;
- }
- $post = get_post( $post_id );
- $post_excerpt = $post->post_excerpt;
- if ( empty( $post_excerpt ) ) {
- $post_excerpt = $post->post_content;
- }
- $post_excerpt = preg_replace( '/\[[^\]]+\]/', '', $post_excerpt );
- $post_excerpt = wp_trim_words( $post_excerpt, 9999, '' );
- $post_excerpt = substr( $post_excerpt, 0, 50 ) . ' ...';
- return $post_excerpt;
- }
- add_filter( 'jnews_module_excerpt', 'custom_trim_by_character', 10, 4 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement