-
shaunkillian
Hey
I am working on a staging site (below)
I have set the Post Excerpt length in the GB Query Look Block to 24 and on the backend, it looks correct. SeeYet, on the frontend, the excerpt lengths are very different. See
Can you please help me fix this?
Thanks
Shaun -
Fernando
Hi Shaun,
Do you have custom Excerpts enabled for those posts? Reference: https://docs.generatepress.com/article/excerpt-issues/#read-more-label-or-button-not-showing
-
shaunkillian
Hey Fernando
Yes, I am using the custom excerpt.
1. I added the following PHP with no effect
add_filter( 'generate_show_excerpt', function( $show ) { if ( 'standard' !== get_post_format() && ! $show ) { return true; } return $show; } );
2. I checked, and the More tage is not being used. Any other ideas?
Cheers
Shaun -
Fernando
Could you share admin login credentials? I’ll check what’s going on.
-
shaunkillian
Sure Fernando
You may have noticed I have also asked for help on the same site and page for ‘except lengths’.
The login link is below.
Cheers
Shaun -
Fernando
This is what I meant: https://share.zight.com/lluOoZlA
You have a custom Excerpt, and by default, that entire custom Excerpt would show no matter what value you place in the limit.
You’ll need custom PHP to limit it if you want.
1. Add
custom-excerpt
to the class list of that Headline. Adding Custom Classes: https://wordpress.com/support/wordpress-editor/adding-additional-css-classes-to-blocks/2. Add this snippet:
add_filter('generateblocks_dynamic_content_output', function($content, $attributes, $block){ if ( ! is_admin() && ! empty( $attributes['className'] ) && strpos( $attributes['className'], 'custom-excerpt' ) !== false ) { $custom_excerpt = get_the_excerpt(); $limited_excerpt = wp_trim_words( $custom_excerpt, 20, '' ); $content = $limited_excerpt.'→'; } return $content; }, 10, 3);
Replace 20 with your preferred limit value.
Adding PHP: https://docs.generatepress.com/article/adding-php/#code-snippets
-
shaunkillian
Thx Fernando
I appreciate your help. Unfortunately, it didn’t work (see video below).
Any other ideas?
Cheers
Shaun -
Check Fernando’s #1 step here:https://generate.support/topic/excerpt-length-in-gb-query-loop-block/#post-88194
You need to add the class
custom-excerpt
to the headline block which represents the excerpt. -
shaunkillian
Thx Again Ying (& Fernando)
-
You are welcome 🙂
- You must be logged in to reply to this topic.