[Resolved] Excerpt not displaying exact number of words in one post

Home Forums Support [Resolved] Excerpt not displaying exact number of words in one post

Home Forums Support Excerpt not displaying exact number of words in one post

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1661271
    Patricia

    Hi there,

    I have set the number of words for the excerpt to 20 but one post (‘HOW TO COOK A RIBEYE STEAK IN A FRYING PAN’) exceeds the number of words making the row not aligned https://prnt.sc/zto2ik

    please help. thanks

    https://www.myhomeselection.co.uk/blog/

    #1661567
    David
    Staff
    Customer Support

    Hi there,

    try adding this CSS:

    .generate-columns .inside-article,
    .generate-columns .inside-article .entry-summary,
    .generate-columns .inside-article .entry-summary p {
      width: 100%;
      box-sizing: border-box;
      display: flex;
      flex-direction: column;
      flex: 1;
      justify-content: space-between;
    }
    #1662510
    Patricia

    Hi David,

    thanks for your reply.

    nope didnt work. it affects the last post.

    what I was concerned about was this post ‘How To Cook A Ribeye Steak In A Frying Pan’ https://prnt.sc/zwvsvf as it has more words than the others.. the except should not go beyond 20 words as I have set it here https://prnt.sc/zto2ik.

    #1662865
    Elvin
    Staff
    Customer Support

    Hi there,

    We can try forcing a trim on the excerpt.

    Try this PHP snippet:

    add_filter( 'wp_trim_excerpt', 'tu_excerpt_metabox_more' );
    function tu_excerpt_metabox_more( $excerpt ) {
        $output = $excerpt;
        if ( has_excerpt() ) {
            $output = sprintf( '%1$s <p class="read-more-button-container"><a class="button" href="%2$s">%3$s</a></p>',
                wp_trim_words( $excerpt, 20, '...' ),
                get_permalink(),
                __( 'Read more', 'generatepress' )
            );
        }
        return $output;
    }

    Here’s how to add PHP
    https://docs.generatepress.com/article/adding-php/

    A wise man once said:
    "Have you cleared your cache?"

    #1663001
    Patricia

    Hi Elvin,

    yup i tried this code before but didnt work.

    anyways, i had it fixed now. thankyou for your help ๐Ÿ™‚

    #1663897
    Elvin
    Staff
    Customer Support

    Nice one. Thank you for letting us know. Glad you got it sorted. ๐Ÿ˜€

    A wise man once said:
    "Have you cleared your cache?"

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.