• Resolved vincent.jiang

    (@vincentjiang)


    I want to just show only 200 words in home page post slide show. which file and where should I modify.

    thanks
    Vincent

Viewing 11 replies - 1 through 11 (of 11 total)
  • Don’t Edit Codes… Just add 200 Words in the Slider Content Box..More easy ??

    Thread Starter vincent.jiang

    (@vincentjiang)

    I am talking about the posts below the portfolio in home page. they are the latest post, can not be hard coded.

    Thread Starter vincent.jiang

    (@vincentjiang)

    Never mind. it turn out wordpress excerpt can not handle chinese well.

    Use child theme for editing/modifying the main theme.

    Thread Starter vincent.jiang

    (@vincentjiang)

    do you mean enigma as child theme? sorry, I am new to wordpress

    For child theme to use child theme creator plugin.

    After that edit/modify the code as per your requirement.

    Thanks

    Add home-blog.php file in child theme.

    After that open this file and find given code

    <?php the_excerpt( __( 'Read More' , 'weblizar' ) ); ?>

    or Replace by below given code.

    <?php echo substr(get_the_excerpt(), 0, 200); ?>

    Save it.

    Thanks

    weblizar, thanks for recommending my plugin ??

    Thread Starter vincent.jiang

    (@vincentjiang)

    Hi, weblizar. It looks like this them doesn’t support child theme. Or it is a bug. the child theme style.css is never loaded.

    thanks

    Child theme support our theme.

    But we provide quick steps for your issue.

    Open the home-blog.php.

    Find the given code
    <?php the_excerpt( __( ‘Read More’ , ‘weblizar’ ) ); ?>

    And Replace by
    <?php echo substr(get_the_excerpt(), 0, 200); ?>
    above given code.

    Save it.

    Thanks

    I did almost the same thing but didn’t want to split any words. This is what I put in instead of <?php echo substr(get_the_excerpt(), 0, 200); ?>.

    <?php 
    
    /* This is the code to split the article after number of words defined in $maxWords */
    
    // Split the excerpt at each space and load into an array
    $excerptArray = explode(' ', get_the_excerpt());
    
    // Define the maximum number of words you want to display
    $maxWords = 200;
    
    // Define the variable that will contain the final, condensed excerpt
    $excerptFinal = "";
    
    // Keep adding words into a variable from the array until $maxWords is reached
    for ($i = 0; $i < $maxWords; $i++){
        $excerptFinal .= $excerptArray[$i]." ";
    }
    
    // If the excerpt is greater than $maxWords, add ellipsis
    if(count($excerptArray)>=$maxWords){
        $excerptFinal .= "...";
    }
    
    echo $excerptFinal;
    
    ?>

    I also added <p>?</p> before the button and encased the button in paragraph tags to give a little bit of padding from the excerpt.

    EDIT: I just messed around with it a bit, I had it set at max 50 characters when I did it on my page, not 200. Looks like excerpt stops at 55 anyways, so the most you should get out of that is 55 words. The only thing my code would do is limit up to the 55 and add the ellipsis.

Viewing 11 replies - 1 through 11 (of 11 total)
  • The topic ‘how to show post summary with 200 word in home page post slide show case?’ is closed to new replies.