Home > Databases, MySQL, Technical, apache, wordpress > Generate your own Wordpress Permalink without GUIDs from database

Generate your own Wordpress Permalink without GUIDs from database

March 1st, 2010

If you are generating links to your blog articles via some other mechanism than Wordpress itself you usually have to use the guid database field. This is the unique global indentifier of the post. In reality it is not globally unique but only unique to your blog.

Typically, the guid in the database will look something like this:

http://blog.bit-matrix.com/?p=2411

You can use this perfectly fine but it will hurt your SEO since search sites prefer descriptive links such as:

http://blog.bit-matrix.com/2010/02/10/google-buzz-a-privacy-disaster

As it turns out, you can easily construct this link from the database yourself. Wordpress will recognize the format of the link and display the appropriate post. The query to construct this is quite simple, all we need is a little date formatting:

SELECT CONCAT(DATE_FORMAT(post_date,’%Y/%m/%d/’),post_name) AS permalink FROM wp_posts WHERE post_status=’publish’;

This will return all the published post guid’s in the following format:

2010/02/10/google-buzz-a-privacy-disaster

That’s all!

Databases, MySQL, Technical, apache, wordpress , , ,

  1. No comments yet.
  1. No trackbacks yet.