Creating a Seamless Redirect Page in WordPress
You want a WordPress page that appears in your navigation menu or URL structure but immediately sends visitors to an external domain, such as sending a "My Photos" link directly to Flickr. While you might be tempted to use a custom PHP template to inject a header() redirect, there are cleaner, more maintainable ways to handle this without needing deep PHP expertise.
The most straightforward approach is to implement the redirect logic within the page's content area using PHP and then assign that page a "Custom" template. This allows you to keep your standard theme files intact while injecting specific behavior for this single page.
To set up the redirect, open or create a file named page-redirect.php in your theme directory (or inside a child theme). Inside this file, place the following code at the very top:
<?php
// Define the target URL immediately upon loading
header("Location: https://www.flickr.com/photos/yourusername/", true);
exit();
?>
It is critical that these lines appear before any HTML output or whitespace. PHP stops execution as soon as exit() is called, ensuring no part of your standard page template (like the header or footer) renders first. If you place this logic in a generic page.php file without a specific template assignment, it will redirect every page on your site, which defeats the purpose.
After creating this file, go to the WordPress admin dashboard, navigate to Appearance > Theme File Editor (if available) or simply upload the file via FTP/SFTP if you are using a custom theme. Then, create the new page in the editor. In the "Page Attributes" meta box on the right side, change the Template dropdown from "Default" to your newly created page-redirect.php.
This method works because WordPress loads the template file specified in the attributes before rendering the body content. The redirect happens instantly during the initial request phase, effectively bypassing the rest of the page load cycle.
However, there are trade-offs to consider with this manual approach. Every time a user visits this page, your server executes PHP to issue a 301 or 302 status code. For simple redirects, this is negligible, but it adds a tiny amount of overhead compared to server-level redirects. Furthermore, if you ever switch themes or accidentally delete the custom template file, the redirect logic breaks unless you have a backup.
An alternative strategy involves using a .htaccess file if your host supports Apache. You can create a dedicated directory for this page (e.g., /photos/) and add a rule to the root .htaccess:
RewriteRule ^photos/?$ https://www.flickr.com/photos/yourusername/ [R=301,L]
Then, name your WordPress page photos instead of creating a unique slug. This method offloads the work to the web server rather than PHP, resulting in faster response times and lower CPU usage on your application server. It also ensures the redirect persists even if you change themes, provided the .htaccess rules remain untouched.
If you prefer not to touch configuration files or handle template assignments manually, WordPress plugins offer a drop-in solution. Tools like "Redirect Manager" or "WP Redirect" allow you to define custom slugs that trigger redirects without writing code. While this requires installing additional software and introduces potential conflicts with other plugins, it provides a user-friendly interface for managing URL mappings.
Ultimately, the choice between a custom template, server-level rules, or a plugin depends on your comfort level with file management and how tightly coupled you want the redirect to be with your theme architecture.