Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Excerpt limit is overruled #48403

Closed
jeffreyvr opened this issue Feb 24, 2023 · 4 comments
Closed

Excerpt limit is overruled #48403

jeffreyvr opened this issue Feb 24, 2023 · 4 comments
Labels
[Block] Post Excerpt Affects the Post Excerpt Block [Type] Bug An existing feature does not function as intended [Type] Regression Related to a regression in the latest release

Comments

@jeffreyvr
Copy link

jeffreyvr commented Feb 24, 2023

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

  1. Create a page called 'Home' and setting it as the 'Homepage' in Settings -> Reading.

  2. 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.
  1. 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; ?>
  1. 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

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

@tmanhollan
Copy link

Came here to report this as well. I believe it's this line:

The condition always evaluates to true because the constant, REST_REQUEST is quoted. And I'm not sure, but if the purpose of this was to determine whether the the editor is active, I think the logic should be AND not OR.

tmanhollan added a commit to tmanhollan/gutenberg that referenced this issue Feb 28, 2023
REST_REQUEST constant was mistakenly quoted, which caused the condition to always evaluate to true. And the conditional logic should be AND, not OR.
@kathrynwp kathrynwp added [Type] Bug An existing feature does not function as intended [Type] Regression Related to a regression in the latest release [Block] Post Excerpt Affects the Post Excerpt Block labels Feb 28, 2023
@skorasaurus
Copy link
Member

Came here to report this as well (and thanks @jeffreyvr for the very detailed test case).

I am able to reproduce this under additional conditions:

Settings at /wp-admin/options-reading.php are set to "Your homepage displays": "your latest posts" ;

used a couple different classic themes (maxwell, ernesto) and in both, the excerpt_filter is ignored even when the priority is manually changed to 999.

@jeffreyvr
Copy link
Author

#48654 fixes this particular issue.

@skorasaurus
Copy link
Member

thanks; closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Post Excerpt Affects the Post Excerpt Block [Type] Bug An existing feature does not function as intended [Type] Regression Related to a regression in the latest release
Projects
None yet
Development

No branches or pull requests

4 participants