I can no longer find the thread where I provide a manual solution for this, but as I was about to write it out here I realized you can (these days) easily roll it into a plugin. So:
Override the_permalink()
Download plugin | View source
When the plugin is activated it will look for any post with a custom field key of ‘url’ and (hopefully) the url you want to change the permalink *to* as the value.
It has a few user-configurable variables you should know about:
$custom_key
= The custom field key the plugin looks for. Default is 'url'
.
$only_on_single
= If you only want to alter the permalink on individual post (permalink) pages, change this to true
(false
is the default, which means the plugin will override the_permalink() everywhere on your blog!).
You can edit the variables either through the Plugin Editor in WordPress, or in a text editor off-line.
—–
If you want this in a few specific places on your blog, here’s a manual method… Before where the_permalink() appears in your template(s), add the following:
<?php
global $post;
$url = get_post_meta($post->ID, 'url', true);
$permalink = ($url) ? $url : get_permalink($post->ID);
?>
Then just change:
<?php the_permalink(); ?>
to:
<?php echo $permalink; ?>