How to Customize WordPress Permalinks
Each WordPress blog post is assigned its own web page, and the address (or URL) of that page is a permalink. Posts that you see in WordPress blogs usually have the post permalink in four typical areas:
The title of the blog post
A Permalink link that appears (in most themes) below the post
The titles of posts in a Recent Posts sidebar
Permalinks are meant to be permanent links to your blog posts (which is where perma comes from, in case you’re wondering). Other bloggers can use a post permalink to refer to that particular blog post. So ideally, the permalink of a post never changes. WordPress creates the permalink automatically when you publish a new post.
By default, a blog post permalink in WordPress looks like this:
The p stands for post, and 100 is the ID assigned to the individual post. You can leave the permalinks in this format, if you don’t mind letting WordPress associate each post with an ID number.
WordPress, however, lets you take your permalinks to the beauty salon for a bit of a makeover so you can create pretty permalinks.
Making your post links attractive
Pretty permalinks are links that are more pleasing to the eye than standard links and, ultimately, more pleasing to search engine spiders. Pretty permalinks look something like this:
Break down that URL, and you see the date when the post was made, in year/month/day format. You also see the topic of the post.
To choose how your permalinks look, choose Settings→Permalinks. The Permalink Settings page opens.
On this page, you find several options for creating permalinks:
Default (ugly permalinks): WordPress assigns an ID number to each blog post and creates the URL in this format: http://yourdomain.com/?p100.
Day and Name (pretty permalinks): For each post, WordPress generates a permalink URL that includes the year, month, day, and post slug/title: http://yourdomain.com/2008/01/01/sample post/.
Month and Name (pretty permalinks): For each post, WordPress generates a permalink URL that includes the year, month, and post slug/title: http://yourdomain.com/2008/01/sample post/.
Numeric (not so pretty): WordPress assigns a numerical value to the permalink. The URL is created in this format: http://yourdomain.com/archives/123.
Custom Structure: WordPress creates permalinks in the format you choose. You can create a custom permalink structure by using tags or variables.
To create the pretty-permalink structure, select the Day and Name (or Month and Name) radio button; then click the Save Changes button at the bottom of the page.
For optimization reasons, a preferred permalink structure is a custom one using the tag %postname% in the Custom Structure field found on the Permalink Settings page. The reason this is preferred is because it strips all the date information and leaves only the post name, or slug, itself.
For example, using the Day and Name structure for permalinks, posts’ permalinks would look like this: http://yourdomain.com/2011/01/02/post title/; however, if the preferred method of %postname% were used the permalinks look like this: http://yourdomain.com/post name. See how it shortens the permalink URL considerably? This is a better method for search engine optimization, and it just looks better.
Customizing your permalinks
A custom permalink structure lets you define which variables you want to see in your permalinks by using tags.
|%year%||4-digit year (such as 2007)|
|%monthnum%||2-digit month (such as 02 for February)|
|%day%||2-digit day (such as 30)|
|%hour%||2-digit hour of the day (such as 15 for 3 p.m.)|
|%minute%||2-digit minute (such as 45)|
|%second%||2-digit second (such as 10)|
|%postname%||Text — usually, the post name — separated by hyphens (such as making-pretty-permalinks)|
|%post_id%||The unique numerical ID of the post (such as 344)|
|%category%||The text of the category name that you filed the post in (such as books-i-read)|
|%author%||The text of the post author’s name (such as lisa-sabin-wilson)|
If you want your permalink to show the year, month, day, category, and post name, select the Custom Structure radio button in the Permalink Settings page and type the following tags in the Custom Structure text box: /%year%/%monthnum%/%day%/%category%/%postname%/
Under this permalink format, the link for the WordPress For Dummies post made on February 1, 2008, filed in the Books I Read category, would look like this: http://yourdomain.com/2008/02/01/books-i-read/wordpress-for-dummies/
Be sure to include the slashes before tags, between tags, and at the very end of the string of tags. This format ensures that WordPress creates correct, working permalinks by using the correct re_write rules located in the htaccess file for your site.
Changing the structure of your permalinks in the future affects the permalinks for all the posts on your blog for both new and old. Keep this fact in mind if you ever decide to change the permalink structure. An especially important reason: Search engines (such as Google and Yahoo!) index the posts on your site by their permalinks, so changing the permalink structure makes all those indexed links obsolete.
Don’t forget to click the Save Changes button at the bottom of the Permalink Settings page; otherwise, your permalink changes won’t be saved!