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

Homepage Posts: Add option to change excerpt length #605

Closed
wants to merge 2 commits into from

Conversation

laurelfulford
Copy link
Contributor

@laurelfulford laurelfulford commented Oct 21, 2020

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 -- filter the_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:

  1. Make sure you have a few recent posts with the following settings: a regular post; a very short (< 10 words) post, a post with a longer custom excerpt, and a post that has the post format set to aside.
  2. Apply the PR and run npm run build.
  3. Create/edit a page and add the Homepage Posts block.
  4. With the block selected, confirm that there is now a range slider in the right column, under the Post Control Settings, with a default value of 55:

image

  1. Toggle off the Show Excerpt option and confirm that the range slider disappears, too.
  2. Toggle Show Excerpt back on again.
  3. Adjust the excerpt length up and down. Confirm that only the posts with the dynamically generated excerpt are affected, and that the excerpt length changes in the preview. Note: By default in WordPress, Custom Excerpts are displayed in full, and we've designed the Aside post format to display the full-content in the blocks, too. Because of this, I opted to only have this slider affect the dynamically generated excerpts, but am open to feedback on that!
  4. Publish the post.
  5. Confirm that your custom excerpt length is also reflected on the front end.
  6. Try steps 7-9 with both longer, and shorter excerpts, to confirm it works as expected.

image

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully ran tests with your changes locally?

Copy link
Contributor

@dkoo dkoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@laurelfulford This treatment works for me. I'll approve for now but will re-review if you want to try the excerpt_length filter instead.

@laurelfulford
Copy link
Contributor Author

Just adding a note that this may be replaced with #607, so it shouldn't be merged unless that one doesn't seem like a suitable approach.

@laurelfulford
Copy link
Contributor Author

#607 will replace this PR, so closing it for now!

@laurelfulford laurelfulford deleted the adds/excerpt-length branch November 12, 2020 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Homepage blocks: Add ability to adjust excerpt length
2 participants