- This topic has 9 replies, 2 voices, and was last updated 3 years ago by
Fernando.
-
AuthorPosts
-
February 14, 2023 at 10:38 pm #2533675
Michelle
The excerpts on my blog page vary in length because I am using custom excerpts. Is there a way to make the blog layout masonry so the blog posts beneath don’t have varying gaps above?
Or–alternatively, how can I make my excerpts end evenly? (Perhaps character counts instead of word counts?)
February 14, 2023 at 10:52 pm #2533683Fernando Customer Support
Hi Michelle,
In Appearance > Customize > Layout > Blog, there’s a “Display posts in masonry grid” setting. Reference: https://docs.generatepress.com/article/using-columns-in-the-blog/
In Appearance > Customize > Layout > Blog, you can also set an Excerpt word count. Reference: https://docs.generatepress.com/article/blog-content-layout/
February 15, 2023 at 12:08 am #2533729Michelle
Thank you, but I’m using query loops and elements (also Custom excerpts). The word count settings work, but since long words have several characters and short words have few, the excerpts don’t have the same amount of lines so the Read More buttons are not uniform across grids. Any design advice is appreciated.
February 15, 2023 at 12:18 am #2533737Fernando Customer Support
I see. Query Loops don’t have a Masonry feature yet.
Does this excerpt length setting not work?: https://share.getcloudapp.com/llugPv2X
Moreover, in the upcoming update for GB which should come out hopefully before the month ends, you should be able to align the Read More button you have at the bottom for the posts in the Query.
February 15, 2023 at 12:47 am #2533753Michelle
The update will be wonderfully helpful!
As for the excerpt length setting shown in your screenshot: Right now I have it set at 25. It isn’t 25 characters, it isn’t 25 words, so what is “25” referring to? I have a grid of 3 across. The left excerpt, middle, and right are all different lengths.
If I change the setting to 50, they all show longer excerpts, but none of them are the same.
UPDATE– I found that manual excerpts work well with excerpt length settings because they truncate off when they reach the set length but CUSTOM excerpts sometimes show in their entirety, ignoring the excerpt length settings.
February 15, 2023 at 1:02 am #2533760Fernando Customer Support
It’s word count, not character count.
I see. You’re using a Custom Excerpt. This overrides the excerpt count settings.
You can try adding
trim-cu-excerptto the Headling Block for the excerpt.Adding Custom Classes: https://wordpress.com/support/wordpress-editor/adding-additional-css-classes-to-blocks/
Then, add this snippet:
add_filter('generateblocks_dynamic_content_output', function($content, $attributes, $block){ if ( ! is_admin() && ! empty( $attributes['className'] ) && strpos( $attributes['className'], 'trim-cu-excerpt' ) !== false ) { $content = substr($content,0,30) . '...'; } return $content; }, 10, 3);February 16, 2023 at 4:14 pm #2536146Michelle
FERNANDO! You’re a genius!
I am so happy with this. It looks so much better.
Thank you!
February 16, 2023 at 5:04 pm #2536167Michelle
Oh…I do have one more concern. Which part of the snippet sets how many words to show? The back end editor shows the correct excerpt length when I adjust it, but the front end only shows a small portion of the excerpt.
Setting:
https://imgur.com/pjfxiuPBack End:
https://imgur.com/NfoZoWxFront End:
https://imgur.com/JiF3Y74UPDATE:
I think I figured it out. I changed this part (it must be a character count)
February 16, 2023 at 5:12 pm #2536170Michelle
Thank you again!
February 16, 2023 at 5:40 pm #2536202Fernando Customer Support
Yes, you’re correct. That value alters the excerpt length.
You’re welcome, Michelle!
-
AuthorPosts
- You must be logged in to reply to this topic.