This topic has 14 replies, 3 voices, and was last updated 7 years by Radu.

  • Author
  • #154607
     andre_placido
    Participant

    Hi! I’ve seen many posts regarding the excerpt lenght, and i’ve tried 2 or 3 functions, but none of them worked. I want the excerpt in the wordpress blog page to be larger. Is it possible?

    Even if I place a “Read More” tag inside the post, or type a text in the Excerpt area, the lenght is still reduced.

     

    Can you help me? The URL is http://www.agenciabowie.com.br/blog

     

    Thank you!

    #154720
     Laura
    Moderator

    Hello, will assign the ticket to a higher support level who can help and advise you in your query.
    Thanks! ?

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution

    Laura Solanes - Graphic Designer and Web Designer

    Please be patient as I try to answer each topic as fast as i can.

    If you like the theme or the support you've received please consider leaving us a review on Themeforest!

    Always happy to help you 🙂

    #154755
     andre_placido
    Participant

    Thanks!I’ll keep waiting, then 🙂

    #154906
     Radu
    Moderator

    Hi,

    Please add the next functions to : http://pastebin.com/raw/SHLbs6Bv
    The functions needs to be pasted in wp-content/themes/kleo-child/functions.php

    Cheers
    R.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #155006
     andre_placido
    Participant

    I’ve tried, then cleanup my cache, but it’s still not working 🙁

    #155065
     Radu
    Moderator

    Do you have Kleo child theme installed and activated ? It’s required

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #156339
     andre_placido
    Participant

    Hi! Sorry for taking so long to answer, and yes, the installed theme is the Child one. I’ll create a temporary user so you can check.

    #156340
     andre_placido
    Participant
    This reply has been set as private.
    #156376
     Radu
    Moderator

    Hi,

    The login credentials are not correct

    Cheers
    R.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #156481
     andre_placido
    Participant
    This reply has been set as private.
    #156601
     Radu
    Moderator

    Hi,

    Done I’ve replaced the function

    See screenshot


    I’ve used this function

    COPY CODE
    
    if ( ! function_exists( 'kleo_excerpt' ) ) {
        function kleo_excerpt( $limit = '', $words = false ) {
            $full_post_content = get_the_content();
            $limit = '99999';
            $excerpt = wp_strip_all_tags(substr( $full_post_content, 0, $limit ));
            return '<p>' . $excerpt . '</p>';
        }
    }
    

    Cheers
    R.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #156806
     andre_placido
    Participant

    Thanks! It worked, however, it’s not working when I put a “read more” tag or write an excerpt in the proper field for it. Is there a way to fix this?

    #157219
     Radu
    Moderator

    Hi,

    Please replace all of that code with this one, the excerpt tag will work as it should

    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( '<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 '' . $excerpt . '
    ';
        }
    }
    
    function kleo_new_excerpt_length( $length ) {
        return 500;
    }
    
    add_filter( 'excerpt_length', 'kleo_new_excerpt_length' );
    

    You can replace 500 value with your desired excerpt length

    Cheers
    R.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #157221
     andre_placido
    Participant

    Hi! Sorry, it didn’t work 🙁

    It resulted in the error message: “Parse error: syntax error, unexpected ‘;’ in /home/agenc750/public_html/wp-content/themes/kleo-child/functions.php on line 35”

    #157499
     Radu
    Moderator

    Hi,

    We have some issues with syntax highlighter function

    Paste again the code from here : https://pastebin.com/raw/u7x9ZUE7 and replace the limit with your desired character

    Let me know

    Cheers
    R.

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
Viewing 15 posts - 1 through 15 (of 15 total)

The forum ‘Bugs & Issues’ is closed to new topics and replies.

Log in with your credentials

Forgot your details?