Using Permalinks in Wordpress

November 1st, 2008 by SwaraTechPrint This Post

bookmark bookmark bookmark bookmark bookmark

There are three basic types of WordPress permalinks:
The default looks like

http://example.com/?p=N

where N is the Post ID number. It works on all server environments, but it doesn’t look as nice as some of the other options.

mod_rewrite: “Pretty Permalinks”

These are the holy grail of permalinks (see Pretty Permalinks). There are many different formats, but the most common, and most versatile looks like

http://example.com/category/post-name/
or  http://example.com/year/month/day/post-name

Some people eliminate some or all of the date elements (day, month, year) to have a shorter permalink format. mod_rewrite permalinks require Apache’s mod_rewrite module.

PATHINFO: “Almost Pretty”

PATHINFO permalinks look very much like mod_rewrite permalinks but for one exception: they have /index.php inserted before them, like so:

http://example.com/index.php/yyyy/mm/dd/post-name/

Otherwise, they are the same as the “pretty” mod_rewrite permalinks, and are similarly flexible. Anything that mod_rewrite permalinks can do, PATHINFO permalinks can do, with the help of that /index.php part.

There is a helpful plugin that displays the type of permalinks being used and detailed information on the internal rewrite rules used by WordPress.

Choosing your permalink structure

In the Settings → Permalinks panel (Options → Permalinks before WordPress 2.5), you can choose one of the “common” structures or enter your own in the “Custom structure” field using the structure tags.

To activate PATHINFO permalinks, start your permalink structure with index.php/.

Structure Tags

You can use these tags to customize your “Pretty” or “Almost Pretty” permalinks. Make sure to end your structure with either %post_id% or %postname% (e.g. /%year%/%monthnum%/%day%/%postname%/) so that each permalink points to an individual post.

%year%
The year of the post, four digits, for example 2004
%monthnum%
Month of the year, for example 05
%day%
Day of the month, for example 28
%hour%
Hour of the day, for example 15
%minute%
Minute of the hour, for example 43
%second%
Second of the minute, for example 33
%postname%
A sanitized version of the title of the post (post slug field on Edit Post/Page panel). So “This Is A Great Post!” becomes this-is-a-great-post in the URI (see Using only %postname%)
%post_id%
The unique ID # of the post, for example 423
%category%
A sanitized version of the category name (category slug field on New/Edit Category panel). Nested sub-categories appear as nested directories in the URI.
%author%
A sanitized version of the author name.

Rate It!
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

Leave a Reply

RSS Feed