Warning: mysql_query(): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /home/content/09/14001309/html/wordpress/wp-content/themes/wardelldesign/header.php on line 103

Warning: mysql_query(): A link to the server could not be established in /home/content/09/14001309/html/wordpress/wp-content/themes/wardelldesign/header.php on line 103

Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in /home/content/09/14001309/html/wordpress/wp-content/themes/wardelldesign/header.php on line 107

Warning: implode(): Invalid arguments passed in /home/content/09/14001309/html/wordpress/wp-content/themes/wardelldesign/header.php on line 113
Redirect a WordPress Post to its Permalink | Wardell Design Blog

Redirect a WordPress Post to its Permalink

By: , On Sunday, August 30th, 2009

I realize the title of this post may sound a little redundant, but I’ve noticed something peculiar in WordPress, it seems that it will automatically redirect a page if you change the page name (aka slug) but wont bother with anything else in the URL. Case in point I recently published a blog but forgot to set the category name, and my WordPress URLs are set to include the category name as follows http://domain.com/category/slug/ so after I updated the post category I realized the post was still accessible using the old category name in the URL without redirecting, as well as with the new category name, I then noticed I could pretty much type in any category name as long as the slug was right the post would still load, this may be fine or even good from a purely functional stand point but not something you want from an SEO perspective, but luckily you can get the correct permalink and make sure the post redirects there using a couple of built in WordPress functions. Below is the code I placed in the head of my template which makes sure all post direct to the proper permalink.

One Response to “Redirect a WordPress Post to its Permalink”

  1. Redstage Magento Says:

    Thanks for this information. This will come in handy soon!

Loading Facebook Comments ...

© Wardell Design 2020
Entries (RSS) and Comments (RSS).