This topic has 13 replies, 3 voices, and was last updated 9 years by Radu.

  • Author
  • #122711
     AntKat
    Participant

    Your 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 );

    ?>

    #122836
     Radu
    Moderator
    Not marked as solution
    #122846
     AntKat
    Participant
    Not marked as solution
    #122905
     Radu
    Moderator
    Not marked as solution
    #122920
     AntKat
    Participant
    Not marked as solution
    #122930
     Radu
    Moderator
    Hi, Try this function instead
    
    
    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 . '
    ';
        }
    }
    Replace 80 with your desired value Cheers R.
    #123098
     AntKat
    Participant
    Not marked as solution
    #123140
     Radu
    Moderator
    Not marked as solution
    #123142
     AntKat
    Participant
    Not marked as solution
    #123149
     Radu
    Moderator
    Not marked as solution
    #147207
     jwchameleoncorp
    Participant
    Not marked as solution
    #147284
     Radu
    Moderator
    Not marked as solution
    #147299
     jwchameleoncorp
    Participant
    Not marked as solution
    #147443
     Radu
    Moderator
    Not marked as solution
Viewing 14 posts - 1 through 14 (of 14 total)

You must be logged in to reply to this topic.

Log in with your credentials

Forgot your details?