Get better excerpt · Whole-Word excerpts, no Mid-Word cuts

Christopher Ross

2 min read

WordPress & CMS engineering · Fort Erie, Ontario

WordPress trims excerpts by counting characters, which means it will happily cut a word in half. You end up with “the project was near comple” trailing off into nowhere. I wrote this so excerpts stop at whole words instead.

What you get

  • Drop-in replacement for get_the_excerpt() that returns whole words
  • Trims to your chosen length, then backs up to the last complete word instead of slicing through one
  • No settings page. It does its one job wherever your theme pulls the excerpt.

Who it’s for

Anyone whose post listings, archive pages, or related-post blocks show automatic excerpts and occasionally cut a word in two. WordPress 5.4 and later handle this better than core once did, but the mid-word cut still shows up in some edge cases, especially with multibyte characters and custom excerpt lengths. If you have never seen a chopped word in your excerpts, you do not need this.

How to install

  1. Download the ZIP from GitHub.
  2. Go to Plugins, then Add New, then Upload Plugin.
  3. Select the ZIP and click Install Now.
  4. Activate.

Status note

This is an archived plugin. Originally published on WordPress.org, now maintained on GitHub and reviewed for security. Still works on current WordPress. No new features planned.

File details

License: GPL-2.0-or-later
Tested with: WordPress 6.7 · PHP 8.1+
Format: .zip

Other downloads from this practice

  • HTML5 Search for WordPress. Another small markup improvement.
  • Auto Copyright. Set your footer copyright once and forget it.

Working through something on your own site? Get in touch →

Leave a Reply

Your email address will not be published. Required fields are marked *

Your rating (optional)

Your name and email are stored with your comment; only your display name is shown publicly. See our privacy policy.