-
Author
-
August 7, 2018 at 02:57 #205639jrozsaParticipant
This seems like something that would have been added by now, but I do not see it. It isn’t still a manual code change, is it?
August 7, 2018 at 16:31 #205689RaduModeratorHi,
1.
The limit can be changed by addind the next codes to /wp-content/themes/kleo-child/functions.phpReplace 350 with your desired number or characters
Code below:
COPY CODEif ( ! function_exists( 'kleo_excerpt' ) ) { function kleo_excerpt( $limit = 50, $words = false ) { /*Force excerpt length*/ $limit = 350; $from_content = false; $excerpt_initial = get_the_excerpt(); if ( $excerpt_initial == '' ) { $excerpt_initial = get_the_content(); $from_content = true; } $excerpt_initial = preg_replace( '<code>\[[^\]]*\]</code>', '', $excerpt_initial ); $excerpt_initial = strip_tags( $excerpt_initial ); /* If we got it from get_the_content -> apply length restriction */ if ( $from_content ) { $excerpt_length = apply_filters( 'excerpt_length', $limit ); $excerpt_initial = wp_trim_words( $excerpt_initial, $excerpt_length, '' ); } if ( $words ) { $excerpt = explode( ' ', $excerpt_initial, $limit ); if ( count( $excerpt ) >= $limit ) { array_pop( $excerpt ); $excerpt = implode( " ", $excerpt ) . '...'; } else { $excerpt = implode( " ", $excerpt ) . ''; } } else { $excerpt = substr( $excerpt_initial, 0, $limit ) . ( strlen( $excerpt_initial ) > $limit ? '...' : '' ); } return '<p>' . $excerpt . '</p>'; } } function kleo_new_excerpt_length( $length ) { return 350; }
Child theme needs to be installed and activated.
Cheers
RHi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution -
AuthorPosts
Viewing 2 posts - 1 through 2 (of 2 total)
The forum ‘General questions’ is closed to new topics and replies.