-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
the_excerpt() function return excerpt with different length in page load and ajax request #53570
Comments
Hi, |
Hello all 👋 I've closed the Trac ticket as there's nothing actionable in that ticket as the work has to happen here in Gutenberg. But for context, I'll bring over the history.
As this issue has been flagged as important within Core, if it gets resolved before WP 6.4 RC1, please include in the cherry picks for package updates. cc @annezazu @bph (6.4 Editor Triage Leads) for awareness. |
I'm working on this issue. |
@anton-vlasenko There's a PR opened here #53571 |
@apeatling, in my tests, #53571 doesn't resolve the issue. I still see the wrong excerpt length when loading posts via AJAX requests. I'm about to submit another PR, and I'm currently testing it. |
Okay 👍 |
@apeatling I've submitted my pull request. It's ready for testing. UPD: I've updated the testing instructions. |
In https://core.trac.wordpress.org/changeset/58065 I just added support for the This can now be used in the post excerpt block to properly modify the excerpt length in a non-hacky way. |
Hi folks, |
This finally needs a PR. Unfortunately |
Description
This issue was reported by @sarathlal in WordPress core Trac: https://core.trac.wordpress.org/ticket/59043
Suppose, we are using the_excerpt() function in a post loop that displays posts from a custom WP query for the "Post" post type. Using the same query with pagination parameter and same post loop to display more posts using AJAX.
Recently it was noticed that the excerpt length was different on page load & AJAX load. Another user also raised a related support thread in the support forum.
https://wordpress.org/support/topic/unexpected-behavior-in-post-loop-after-sending-ajax-request/
It was decided that the issue needed to have fixed from Gutenburg at first, on the file:
gutenberg/packages/block-library/src/post-excerpt/index.php
Lines 80 to 95 in d5d8533
Step-by-step reproduction instructions
Here is the custom code used in theme.
Code in home page template.
Code in template-parts/post-card.php
Jquery code for "Load more" button
Now on the initial page load, the excerpt length will be 50 words if there is no filter. But when I click on the "Load More" button, the length will be 100 words.
Screenshots, screen recording, code snippet
No response
Environment info
No response
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
The text was updated successfully, but these errors were encountered: