Skip to content
Home » News » WordPress Plugin: Slug Trimmer

WordPress Plugin: Slug Trimmer

One of the worst things sometimes is having URLs that go on forever thanks to long post slugs taken from the titles of the posts you make, and so Graeme went ahead and created a plugin to fix those post slugs.

I have got sick of URLs that end in really long post slugs that look-something-like-this-and-are-far-too-long so I wrote a little plugin that shortens post slugs more intelligently than simply truncating them.
It works in two phases. It first removes short words (because words like “a” and “the” are rarely significant), shortest first.
If the slug is still too long, it is then truncated. However slugs will never be truncated mid-word.
The size of words removed the the first phase and both the minimum and maximum lengths of the slug resulting can be configured. Truncation can be turned off. The point at which the slug is truncated is set separately from the maximum for the purposes of phase one (word removal).

An interesting idea, and I agree about the removal of the “a” and “the” as they are usually not needed. You can check out the details of the plugin at Graeme’s.