Homepage Posts: Add option to change excerpt length #605
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
All Submissions:
Changes proposed in this Pull Request:
This PR adds an option to the Homepage Posts block to control the excerpt length. It uses the WordPress default (55 words) as the default, and allows you to increase the length up to 100 words, or down to 10 words.
It appears to work well on Newspack sites but could break some things that currently work on WP.com:
The 'excerpt' is no longer an excerpt, so it will no longer pick up filters for
the_excerpt
. This won't be an issue on Newspack sites, but on WP.com, some themes -- like Varia -- filterthe_excerpt
to replace the[...]
with a "Continue Reading" link.Similarily, things like the share and like buttons can be made to appear with certain settings using themes other than the Newspack theme (since it removes it from the bottom of the content/excerpts).
If this approach otherwise makes sense, adding an option for a Continue Reading link in the block (#495) could be a way to make it behave more consistently and as an alternative for sites that may like this behaviour.
I'm not sure what we can do about the share buttons; they also don't work properly with some settings (like if you have them set for posts and not pages, the buttons will appear, but the icons will not -- #420).
It's possible there's another approach that will maintain the excerpts (filtering the excerpt length on a per-block basis seemed like a bad idea, but maybe it's better than this?), or ways to work around the above (only making the option available when a theme opts in, similar to the Article Subtitle?). I'd be very interested to hear other's thoughts about that!
Closes #22.
How to test the changes in this Pull Request:
npm run build
.Other information: