-
Author
-
May 23, 2016 at 01:39 #122711
AntKat
ParticipantYour theme does not seem to have an option to use custom excerpts. I found the following code snippet in your forum but it does not work. This is the complete child functions.php file at the present time.
<?php
function custom_excerpt_length( $length ) {
return 20;
}
add_filter( ‘excerpt_length’, ‘custom_excerpt_length’, 999 );
?>
May 24, 2016 at 18:09 #122930Radu
ModeratorHi, Try this function instead
Replace 80 with your desired value Cheers R.if ( ! function_exists( 'kleo_excerpt' ) ) { function kleo_excerpt( $limit = 80, $words = true ) { $excerpt_initial = get_the_excerpt(); if( $excerpt_initial == '' ){ $excerpt_initial = get_the_content(); } $excerpt_initial = preg_replace( '<code>\[[^\]]*\]</code>', '', $excerpt_initial ); $excerpt_initial = strip_tags( $excerpt_initial ); if ( $words ) { $excerpt = explode( ' ', $excerpt_initial, $limit ); if ( count( $excerpt ) >= $limit ) { array_pop( $excerpt ); $excerpt = implode( " ", $excerpt ) . '...'; } else { $excerpt = implode( " ", $excerpt ) . ''; } } else { $excerpt = $excerpt_initial; $excerpt = substr( $excerpt, 0, $limit ) . ( strlen( $excerpt ) > $limit ? '...' : '' ); } return '' . $excerpt . ' '; } } -
AuthorPosts
Viewing 14 posts - 1 through 14 (of 14 total)
You must be logged in to reply to this topic.