Site logo

Archived topic

Trouble Setting the Excerpt Length

6 replies · Started by Anthony on December 1, 2020

Viewing posts 1–7 of 7

I can't seem to get the excerpt length to be what I set it to in the Customizer > Layout > Blog settings. Not sure if something else is holding it back somewhere? I've shared a screenshot of my current settings and a link to my blog.

I have tried a combination of other settings and have had no luck.

Thanks

Hey, thanks!

I've never used a more tag in my life haha.

I don't use Gutenberg or Classic Editor for much. Most stuff I do on Siteorigin Pagebuilder.

Do I have to use a more tag in order for the excerpt word count to work? I swear this use to work no problem.

Thanks again!

Will I need to use this?
https://docs.generatepress.com/article/activating-read-custom-excerpt/

This can actually give you clues.

I can’t seem to get the excerpt length to be what I set it to in the Customizer > Layout > Blog settings. Not sure if something else is holding it back somewhere? I’ve shared a screenshot of my current settings and a link to my blog.

By default, WordPress skips all of the excerpt_length and excerpt_more filters when the custom excerpt is used. This means the excerpt length and "read more" button won't work if you're using the excerpt metabox a.k.a. custom/manual excerpt.

To clarify: Are you using the excerpt metabox (custom/manual excerpt)?

If this is the case, you can 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, 2, '...' ),
            get_permalink(),
            __( 'Read more', 'generatepress' )
        );
    }
	
    return $output;
}

Change "2" in wp_trim_words( $excerpt, 2, '...' ) to the preferred excerpt length.

If your post is showing full post content rather than excerpt, check this.
https://docs.generatepress.com/article/excerpt-issues/#full-post-content-displaying-while-using-excerpt

That PHP Snippet worked! Thanks!

No problem. Glad it works for you.:)

This archived topic is closed to new replies.