This topic has 11 replies, 3 voices, and was last updated 8 years by Laura.

  • Author
  • #98915
     ale7q
    Participant

    I am outputting my group’s main topics post onto the front page of kleo through post grid. I am trying to limit the lengths of excerpts using the one’s I saw in the forum (your reply get excerpt function which I placed in the function.php but no change). In fact I can’t find a place to limit the length of excerpts. Neither can I find that in the post template php. I also found your other replies but it showed errors when I placed in my function php.

    Maybe my particular case is different since I am outputting a Group topic post. How to do it.

    #99023
     Laura
    Moderator

    Hello, i understand the issue, can you share admin credentials so i can check it out?

    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 🙂

    #99061
     ale7q
    Participant
    This reply has been set as private.
    #99302
     Laura
    Moderator

    Hello, added this

    COPY CODE
    
    function custom_excerpt_length( $length ) {
        return 20;
    }
    add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );
    

    To functions.php 🙂 You can change it as you prefer ( 20 )

    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 🙂

    #99452
     ale7q
    Participant

    Hi,

    Thanks a lot. Just one more favour, how to change the limits to number of character instead of words words.

    #99780
     Laura
    Moderator

    Hello, try maybe this one

    COPY CODE
    
    function get_excerpt(){
    $excerpt = get_the_content();
    $excerpt = preg_replace(" (\[.*?\])",'',$excerpt);
    $excerpt = strip_shortcodes($excerpt);
    $excerpt = strip_tags($excerpt);
    $excerpt = substr($excerpt, 0, 40);
    $excerpt = substr($excerpt, 0, strripos($excerpt, " "));
    $excerpt = trim(preg_replace( '/\s+/', ' ', $excerpt));
    return $excerpt;
    }
    
    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 🙂

    #107041
     ale7q
    Participant

    Sorry but it did not work — the length did not change at all. Do you another suggestion?

    #107145
     Laura
    Moderator

    Hello, you may need to contact a freelancer to check it out for you

    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 🙂

    #107183
     ale7q
    Participant

    I was hoping you can just give another codes that I can try.

    I am searching this site. Maybe there are some clues somewhere but I could not see them.

    #107258
     Laura
    Moderator

    Hello, try this maybe

    COPY CODE
    
    function excerpt($limit) {
       $excerpt = explode(' ', get_the_excerpt(), $limit);
       if (count($excerpt)>=$limit) {
          array_pop($excerpt);
          $excerpt = implode(" ",$excerpt).'.';
       } else {
          $excerpt = implode(" ",$excerpt);
       } 
       $excerpt = preg_replace('@\[[^\]]*\]@','',$excerpt);
       return $excerpt;
    }
    

    If it doesn’t work you will need to contact a developer 🙂

    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 🙂

    #145030
     Cafonauta
    Participant

    Hi,
    Is this the preferred way to limit post excerpt lenght on post grid?

    COPY CODE
    function custom_excerpt_length( $length ) {
        return 20;
    }
    add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );

    Does it affect only post grid excerpt?

    Thanks

    #145194
     Laura
    Moderator

    Hello, i do not understand your question, does it work for you? You can test the code and check it out 🙂

    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 🙂

Viewing 12 posts - 1 through 12 (of 12 total)

The forum ‘General questions’ is closed to new topics and replies.

Log in with your credentials

Forgot your details?