View Single Post
Old 03-13-2009, 05:45 PM  
fris
Too lazy to set a custom title
 
fris's Avatar
 
Industry Role:
Join Date: Aug 2002
Posts: 55,539
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.

__________________
Since 1999: 69 Adult Industry awards for Best Hosting Company and professional excellence.


My Cam Feeds Script / Gallery Scraper / WPXXX Theme / Free Templates
fris is online now   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote