WordPress: Adding “Page Links To” to Custom Post Types

If you use WordPress (especially as a content management system) and you haven’t heard of Mark Jaquith’s “Page Links To” plugin, you should definitely check it out. Basically, the plugin allows you to set up a WordPress page or post to redirect to a different URL. It can be very handy for setting up redirects, adding menu items for pages that wouldn’t normally appear in those menus, etc.

One issue with the plugin, however, is that it does not (as of version 2.4.1) support custom post types. It only supports WordPress posts and pages. If you want to set a custom post type to redirect to a URL other than its permalink, you can’t do so with this plugin.

However, there is a pretty simple way to add support for custom post types to this plugin; and the changes do not require you to edit the plugin itself. Instead, you can make all of the necessary changes in your theme’s functions.php file.

Redirecting and Duplicating Content Properly

There are certainly times when all Web developers and “information architects” find themselves in a situation where they need to move content from one page to another. When you do so, you need to redirect visitors from the old location to the new location, and you need to do so properly. To do that, you need to make sure that the old location returns the correct status code (301 – Moved Permanently). There are a number of ways to do this. The most efficient way, for apache users, is to set up a redirect inside of your .htaccess file. However, if you don’t have permission to set up redirects within .htaccess, you can use PHP (or any other server-side scripting language) to do so. Using meta refresh tags and javascript is not generally the best way to redirect your visitors.

Rewrite and Redirect for IIS – Sort of

Last week at work, we unveiled one of the new Web sites I’ve been working on for a while.  In doing so, we removed the old Web site completely from the server and replaced it with the new site.

Of course, when we did so, a lot of our old links became obsolete, so I had to find an effective solution to keep our regular visitors from going bananas when they tried to access some of their favorite pages.  That’s when I began to look into some options for redirecting without having to create placeholder pages just for those redirects.  After quite a few fruitless searches, I was able to piece together a fairly good solution, and also discovered an easy way to achieve URL rewriting on an IIS server (similar to the way you would with htaccess on an apache server).

First, you need to set up your “404” so that it points to a VBScript page.  That’s the most important part.  Once you’ve got that done, navigate to a page that you know does not exist on your server, just so you can test the behavior of your 404 page.