PHP, programming, software, Wordpress

Simple WordPress Page Redirect Hack

I recently was looking for a way to setup a WordPress Page that actually was just a link/placeholder for an external site. This allows me to have my external page be automatically part of a theme’s navigation, etc. The solution I used is actually pretty simple and allows for an unlimited number of instances of these “redirect pages” without having to use any external plug-ins.

First you need to setup a simple PHP file that will serve as a template for your new page. Let’s say for example you have a club that you want to add as part of your navigation. Create a file called Club.php and put the following code in it:

Template Name: Club
<?php header('Location:');

Then upload the file you created (Club.php) into /wp-content/themes/yourthemename/ where yourthemename is the name of the active theme for your site.

The final step is to create a new Page with the name that you want to show up in your navigation “My Club” based on the template that you just uploaded. You will see this template under the Template drop down menu in the page administration interface along with “Default Template”, etc.

Publish and you have a page that automatically redirects to whatever the URL you specified in your PHP template file. I create a separate one of these for any of these “redirect pages” that I want to setup.

It’s easy and it works!

Tagged , , , , ,

Leave a Reply

Your email address will not be published. Required fields are marked *