wordpress tip: link (plug) an external site
Sometimes people pay for advertising and want a direct link the site in question, or maybe you just want to link to another site without viewing a post.
I found this cool snippet via http://www.istudioweb.com/hacking-wo...le-2008-01-12/
I edited mine a bit, bascially you add a custom field plug and put the url you want it to goto, if no custom field is set it will be a regular post.
Code:
function plugit() {
global $post;
$post_id = get_post($post->ID);
$title = $post_id->post_title;
$perm = get_permalink($post_id);
$plug = get_post_custom_values('plug');
if (empty($plug)) {
$link = $perm;
}
else {
$link = $plug[0];
}
echo '<a href="'.$link.'" rel="bookmark" title="'.$title.'">';
}
Heres a site of mine I have it in use.
http://i42.tinypic.com/2mg8nc8.jpg
|