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 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 2019
Entries (RSS) and Comments (RSS).