How To Redirect a Page to an External URL in WordPress

First off, credit where credit is due.  This content is based on content found here: http://www.nathanrice.net/blog/how-to-redirect-a-page-using-custom-fields-in-wordpress/

I’ve taken Nathan Rice’s basic concept for internal and external URI redirection with custom fields in WordPress and broken it down into basic steps.

  1.  Connect to your FTP host
  2. Go to the following directory (usually) /home/yoursite/public_html/wp-content/themes/yourtheme/
  3. Open pages.php
  4. Find the following line of code (usually the very first line):
    <?php get_header(); ?>
  5. Replace it with the following code:
    <?php global $post; // < -- globalize, just in case $field = get_post_meta($post->ID, 'redirect', true); if($field) wp_redirect(clean_url($field), 301); get_header(); ?>
  6. Save the changes and upload the file back to your FTP host
  7. Log in to your WordPress site (as an Administrator)
  8. Go to your “Pages” section and click “Add New”
  9. Name the page what you would like the link to be called.  eg. For www.yoursite.com/abc, name the page “abc”
  10. Make sure that “Custom Fields” is checked in “Screen Options” (top right)
  11. Add a custom field called “redirect” and set the value to the URL you would like the site to redirect to
  12. Publish the page
Now, when you browse to your new page, you will automatically be redirected to the URL you entered.

About Ben Inkster

Ben is passionate about business (he started his first business when he was 10 years old). He loves to teach people how technology and business can work together, so he started Internet Business Beginners to help people everywhere start and run their own Internet-Based Business.

View all posts by Ben Inkster

Social Media

No comments yet.

Leave a Reply