Using WordPress Pages to Link to Another Site

You may have noticed that since I changed the theme for this site that there is now a page called “paulmc.org” that directly links back to the root of my website. Unlike a normal WordPress page, this page links to a document completely outside the WordPress hierarchy.

I’m sure that it would be possible to hard-code the link into the theme files, but every time the theme is changed, the changes would have to be re-coded again. There’s also the fact that every theme is slightly different, so each theme change could mean starting from scratch. Instead it’s much easier to update the WordPress database.

Updating the database will ensure that the changes are persistent across theme changes. The downside is that if you’re not careful, you could hose your entire WordPress installation. So if you’re going to do this, make a backup. I’ll say that again – backup your WordPress database before you even think of doing this.

The first step is to create a standard WordPress page. The title of the page should be the name that you want to appear in the link. In my case the page title was “paulmc.org”. Under the discussion tab on the right hand side of the writing pane, untick the “Allow Comments” and “Allow Pings” options. Don’t enter any content and publish the page.

Now it’s time to edit the WordPress database. To do this you’ll need access to phpMyAdmin. Connect to your WordPress database and look for the wp_posts table. Choose the option to browse this table. You now need to locate the entry that corresponds to the page you’ve just created. It should be the last entry in the table.

Now that you have located the page entry, it’s time to edit the database. Click the edit icon. There are two items that you need to change. The first is “post_name”. This should be changed to reflect the URL that you want to link to. If you want to link to a page that is in the root of your website, you need to use relative addressing. For example, in my case, I changed the “post_item” to “../index.php”.

The second item that needs to be changed is the “guid”. This should be changed to the full address that you’re linking to, including the “http://www”.

To apply the changes that you’ve just made, click the Go button. Exit out of phpMyAdmin and you’re ready to test your changes. Refresh your blog and test that the link takes you where you want to go.

Update: Changed the name of database entry from “post_item” to “post_name”.