-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Latest Posts block: Check priority of excerpt_length filter #33027
Copy link
Copy link
Open
Labels
Needs Technical FeedbackNeeds testing from a developer perspective.Needs testing from a developer perspective.[Block] Latest PostsAffects the Latest Posts BlockAffects the Latest Posts Block[Feature] ThemesQuestions or issues with incorporating or styling blocks in a theme.Questions or issues with incorporating or styling blocks in a theme.[Type] EnhancementA suggestion for improvement.A suggestion for improvement.
Metadata
Metadata
Assignees
Labels
Needs Technical FeedbackNeeds testing from a developer perspective.Needs testing from a developer perspective.[Block] Latest PostsAffects the Latest Posts BlockAffects the Latest Posts Block[Feature] ThemesQuestions or issues with incorporating or styling blocks in a theme.Questions or issues with incorporating or styling blocks in a theme.[Type] EnhancementA suggestion for improvement.A suggestion for improvement.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Hi - the excerpt length setting in the latest posts block does not get used in all themes. This seems to be a common problem in themes that change the default excerpt length.
This appears to be a because of the excerpt_length filter in the render method.
gutenberg/packages/block-library/src/latest-posts/index.php
Line 48 in 97caf7b
In the method the filter has a priority of 20, however the official WordPress docs suggest a priority of 999 which I have found referenced on a number of sites and used in many themes.
https://developer.wordpress.org/reference/hooks/excerpt_length/#more-information
I started updating my 20+ themes to use a lower priority but then realised that it's used in so many other themes that it should probably be changed in core.
You can see how many public themes use it here:
https://wpdirectory.net/search/01F9927FX53NQ7AA33DS32YK38
If you expand the top 20 results on this page you will see that about 50% use the 999 priority.
My suggestion would be to use
9999since some people (including myself) may go even higher in child themes.