Skip navigation

WordPress School: Post Slug

Badge - Learn WordPress with Lorelle VanFossen at WordPress School.In the tutorial on creating links in your WordPress content, I mentioned that I’d love to do an entire college course dedicated solely to the power of the hyperlink – it is that fascinating and influential in all things web. So far we’ve talked about links that connect related content on your site together, citation links, how to share links, and about the way WordPress links within the Admin area work and how to, and not, link to preview posts and deal with problematic nonces.

In this tutorial in Lorelle’s WordPress School free online course I’m going to cover one of the smallest and yet most powerful details associated with links in WordPress, the post slug.

The post or Page slug is the title of the post or Page that appears in the permalink, specifically the pretty permalink in WordPress, the contextualized link used for WordPress web pages. By default, the link to a post is example.com/?p=987654. The pretty permalink feature changes the post ID number to the title of your post as how-i-solved-the-post-slug-problem. These are known as URL-friendly version links.

WordPress brought the concept of canonical URLs to WordPress with version 2.4 in 2007, code under the hood that does its best to redirect a link to your post no matter how many times you change the post title or slug.

In the Post or Page Edit Screen of the classic editor, look under the title for the word Permalink The first part of the link in that section is not editable. This reflects the permalink structure set by the web host, such as WordPress.com, or the site administrator. In this example, the pretty permalink structure is set to feature the year, month, and date of the post, followed by the post title, the part that is editable.

Post Slug - Screenshot of the Visual Editor post slug feature - Lorelle WordPress School

To change the post slug, click Edit and make your changes.

You may write whatever you wish and you need not include hyphens or remove punctuation. When you save the permalink, WordPress will automatically clean it up.

Let’s say that this is the title of your post:

Hopin' y'all can make the partee!

After hitting the Publish button, WordPress would clean it up and turn it into this:

example.com/2010/6/5/hopin-yall-can-make-the-partee

WordPress cleans up the title by removing apostrophes, quote marks, and other characters that interfere with the structure and linkability.

Why Change the Post Slug?

Why “Slug?”

The term “slug” comes from the early days of the printing press when hot lead was melted into molds of letters that were used to literally stamp the letters onto paper. The big gray lead mass was nicknamed a slug as it looked much like a giant slug, and the resulting lead words and sentences removed from the mold inherited the name. An expert typesetter in those days could set a line of type and work the machines incredibly fast. Make a mistake and the mold would have to be changed and lead poured in, cooled, and replaced in the chase or galley that held the words for printing. Unlike today’s word processors and blogs with easy editing abilities, once it was printed, there was no turning back.

Letterpress type and lead slugs

Most people ignore the post slug. Write well-formed post titles that explain the purpose of the article and create an urge to click and your post slug will reflect that.

However, you may wish to change the post slug to be different from the post title, or change it when you change the post title so the two will match.

In the above example, hopin-yall-can-make-the-partee might not be very readable to someone just looking at the link or search engines, so you might wish to leave the post title the same and change the post slug to hoping-you-all-can-make-the-party.

Shortening the post slug and changing it for SEO reasons is the most common time the post slug is changed. A title such as everything-i-wanted-to-tell-you-before-i-forgot-and-didnt-want-to-forget-because-life-is-sort-sing-merry-doodle-all-day might be changed to things-i-wanted-to-tell-you.

In the tutorial on what happens in WordPress when a post or Page title is forgotten when publishing, you learned how the post slug becomes the post ID number. Correcting the post title involves also editing the post slug to add the post title unless you wish it to remain the post ID number.

More Information on Post Slugs

For more information on post slugs and related link topics:

Assignment

Lorelle's WordPress School Assignment Badge.Your assignment today is simple. Edit the post slug of a post you have published.

  1. Select a published post and edit it
  2. On the View Post button, right click and open the front end view of the post in a new tab. Let it sit there in your web browser and if your browser switches you to it, go back to the Edit Post tab.
  3. Click Edit under the post title to change the post slug to something different (you may change it back afterward)
  4. Save the post slug edit and update the post
  5. Right click again on the View Post button and choose to open it in a new tab (avoid using the Preview on a published post)
  6. Did the tab open to the view of the post with the new post slug? Or did you get a page-not-found error?
  7. Switch to the already open tab with the view of the same post with the old post slug. Refresh/reload the web page in the browser. Did it automatically switch to the new post address?
    • If the post is part of your article series on your test site, look for a link within one of the articles to that post and click it. Does the article appear at that address?
  8. Once the experiment is complete, you may edit the post slug and return it back to its original name, or leave it alone.

If this works and the changes you made to the post slug returns the post, then the canonical URL process in WordPress is working, and you’ve learned how to edit the post slug in WordPress..

This is a tutorial from Lorelle’s WordPress School. For more information, and to join this free, year-long, online WordPress School, see:

Subscribe to Lorelle on WordPress. Feed on Lorelle on WordPress Follow on Twitter. Give and Donate to Lorelle VanFossen of Lorelle on WordPress.


2 Trackbacks/Pingbacks

  1. […] renaming, start the process now. Go to Posts > Categories and either change the names and the category slug or create a new category and move the posts into […]

  2. […] WordPress School: Post Slug […]

Post a Comment

%d bloggers like this: