-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Closed
Labels
[Block] Post ExcerptAffects the Post Excerpt BlockAffects the Post Excerpt Block[Type] BugAn existing feature does not function as intendedAn existing feature does not function as intended[Type] RegressionRelated to a regression in the latest releaseRelated to a regression in the latest release
Description
Description
Since Gutenberg 15.2.0, the set excerpt length limit is not always respected.
When you have a Homepage set (Settings -> Reading), and have a custom query on front-page.php
, it does no longer limit the length.
This bare bones theme reproduces the issue:
https://github.com/jeffreyvr/gutenberg-excerpt-limit-bug
Step-by-step reproduction instructions
-
Create a page called 'Home' and setting it as the 'Homepage' in Settings -> Reading.
-
Create a posts with text exceeding the excerpt limit. Example:
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer dictum porttitor gravida. Nulla efficitur, enim in ultrices dignissim, augue justo efficitur tellus, et condimentum enim magna id erat. Nam a consectetur magna, dapibus gravida tortor. Nulla quis dapibus massa. Phasellus mattis sem vitae maximus congue. Praesent pharetra vulputate quam a sodales. Quisque in risus turpis. Maecenas eu molestie arcu. Sed sed finibus magna. Integer in rhoncus velit, in luctus turpis. Nam volutpat lorem vel purus ultrices bibendum non vel enim. Duis sem nibh, ultrices quis pulvinar vitae, congue vel lorem. Praesent suscipit risus quis lacinia consectetur. Etiam ornare scelerisque convallis. Aenean id nibh eget massa aliquam laoreet quis non ex. Aliquam non tortor et neque placerat tempus eu non sapien.
Nulla sodales sapien ac nisl luctus, nec finibus odio aliquet. Nunc massa neque, ultricies eu elementum non, vehicula at nulla. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia curae; Donec dapibus enim id varius placerat. Ut vel orci bibendum sem viverra sollicitudin. Sed ullamcorper eros arcu, vehicula pulvinar dui posuere eget. Cras ut nisl sit amet sapien tristique eleifend at vel sapien. Quisque congue, odio vel vestibulum interdum, ex nisl malesuada mauris, ac hendrerit nulla nisi et sem. Nam id risus vestibulum, congue ante in, ornare justo. Vestibulum consequat justo ac eros faucibus, at interdum est placerat.
- The
front-page.php
should contain a custom query to display recent posts.
<?php
$custom_query = new WP_Query( array(
'post_type' => 'post',
'posts_per_page' => 3,
'orderby' => 'date',
'order' => 'DESC',
) );
?>
<?php if ( $custom_query->have_posts() ) : ?>
<?php while ( $custom_query->have_posts() ) : $custom_query->the_post(); ?>
<div>
<h2><?php the_title(); ?></h2>
<div><?php the_excerpt(); ?></div>
</div>
<?php endwhile; ?>
<?php endif; ?>
- In
functions.php
limit the excerpt length:
function example_site_custom_excerpt_length( $length ) {
return 20;
}
add_filter( 'excerpt_length', 'example_site_custom_excerpt_length', 999 );
Screenshots, screen recording, code snippet
Screen.Recording.2023-02-24.at.11.31.36.mov
Environment info
- Gutenberg v15.2.0
- WordPress v6.1.1
- Theme (very basic): https://github.com/jeffreyvr/gutenberg-excerpt-limit-bug
Please confirm that you have searched existing issues in the repo.
Yes
Please confirm that you have tested with all plugins deactivated except Gutenberg.
Yes
Metadata
Metadata
Assignees
Labels
[Block] Post ExcerptAffects the Post Excerpt BlockAffects the Post Excerpt Block[Type] BugAn existing feature does not function as intendedAn existing feature does not function as intended[Type] RegressionRelated to a regression in the latest releaseRelated to a regression in the latest release