To increase or decrease the excerpt length with a custom one, please add this codes to your kleo-child/functions.php and make sure Kleo-child theme is active:

Replace 500 with your desired value for more text use a higher value and also for a less text a lower value, 500 represents number or characters and the new length of the excerpt.

COPY CODE


if ( ! function_exists( 'kleo_excerpt' ) ) {
    function kleo_excerpt( $limit = 50, $words = false ) {
        /*Force excerpt length*/
        $limit = 500;
        $from_content    = false;
        $excerpt_initial = get_the_excerpt();

        if ( $excerpt_initial == '' ) {
            $excerpt_initial = get_the_content();
            $from_content    = true;
        }
        $excerpt_initial = preg_replace( '`\[[^\]]*\]`', '', $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 500;
}

add_filter( 'excerpt_length', 'kleo_new_excerpt_length' );

Log in with your credentials

Forgot your details?