Jeff Starr On Smarter Slugs In WordPress

One of the refinements that was part of WordPress 3.3 is that posts that have certain characters within the post title are ignored thus, creating a cleaner permalink. Jeff Starr of Digging Into WordPress explains in better detail on what actually happens when you use those characters within the post title but further into the post, he also brings up the fact that WordPress can automatically detect duplicate post titles within the database and append a dash with a number to the end of the post title. However, as Dave Clements mentions in the comments, this could possibly lead to broken links:

I read something that’s a little concerning in your post. Let’s assume that I create test-post and then create test-post-2. I publish them both and then trash test-post. Are you saying that test-post-2 will automatically become test-post, potentially screwing up any links that have been published with the original permalink of test-post-2? Just wondering what impact this has.

Perhaps Otto could shed some light as to what happens regarding this scenario. Jeff Starr will be looking into it and will be reporting back his findings.

4

4 responses to “Jeff Starr On Smarter Slugs In WordPress”

  1. To the best of my knowledge, this doesn’t happen at all. Published post slugs don’t get altered automatically by any process.

    Now, you might see this behavior for *drafts*, because a draft isn’t published yet and hasn’t had its slug finalized. But when a post is published, the slug is saved as part of the post in the post_name column, and it doesn’t get altered unless you manually alter it.

    I just ran a quick test and published test-post and test-post-2 (both titles were “test post”). Deleting the first test-post didn’t alter the slug of the second one. Nor should it, I’d think.

  2. Yeah. I’ve done that in the past and the slugs of published posts/pages don’t automatically change when you trash/delete the first post/page. When I’ve done that I’ve had to go back and manually edit the slug of the second page because I wanted it to replace the first one.

  3. … WordPress can automatically detect duplicate post titles within the database and append a dash with a number to the end of the post title.

    I do notice that when I try to use the same child category-term beneath different category-parents, WP automatically modifies the category-slug in this manner (by appending a dash-#), which then generates modified permalinks (while leaving the identical child-terms themselves untouched).

    This results in a modified suggest permalink, ie:

    Two category-trees, geo > alaska > rivers > wild and hike > olympic > rivers > wild become URLs geo / alaska / rivers-1 / wild-1 and hike / olympic / rivers-2 / wild-2 (without spaces).

    As a result, I resist the inclination to use “obvious” recurring category-terms beneath independent category-hierarchies … where indeed the paths themselves are perfectly “unique”. The category names aren’t changed, only the recommended slug (which you can make different in your own manner of chosing), and thus the subsequent URL.

    A separate case, with a similar result.

Newsletter

Subscribe Via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.