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.
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:
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?
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
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
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:
- Understanding The WordPress Post Title and Post Slug
- Changing Titles in The Titles of WordPress Posts
- Dissecting the WordPress Post Title Link
- Change the Post Title – Also Change the Post Slug
- Creating Effective, Attention-Getting Headlines and Titles
- Writing Effective, Attention-Getting Headlines and Titles on Your Blog
- What is Post Slug in WordPress? – WPBeginner
- New Post Screen — Support — WordPress.com
Your assignment today is simple. Edit the post slug of a post you have published.
- Select a published post and edit it
- 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.
- Click Edit under the post title to change the post slug to something different (you may change it back afterward)
- Save the post slug edit and update the post
- 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)
- Did the tab open to the view of the post with the new post slug? Or did you get a page-not-found error?
- 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?
- 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:
- Lorelle’s WordPress School Introduction
- Lorelle’s WordPress School Description
- WordPress School Tutorials List
- WordPress School Google+ Community
- WordPress Publishing Checklist
- How to Give Feedback and Criticism