WordPress plugin: Slug Trimmer

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).

The slug is generated on saving a post (so you get a chance to look at it before publishing), or on publish. It will not overwrite an existing slug, even one generated by itself. You can force the generation of a new slug by deleting the existing one.

Installation and configuration is simple. Download Slug Trimmer here. If you want to change the configuration, the options will appear as a sub-panel of “Options” in your WP Admin.

If you find this plug useful and feel inclined to do me a favour: I would really appreciate links to any of my money-making sites. I most need links to internal pages of Moneyterms, or to either the front page or the books section of PTZ.com.

11 thoughts on “WordPress plugin: Slug Trimmer

  1. Your plugin skips the trimming if the blogger enters the text right in the Post Slug box when posting.

    I tried to hack and then your post slug gets replaced by the title when updating a post.

  2. It is deliberate: I assumed that if someone entered a post slug manually, then that is what they wanted.

    What changes did you make to the code.

Comments are closed.