Considering how regularly new versions of Firefox now come along, that's quite some bug fix list in version 10! http://t.co/K3I2vLpW 1 week ago

22nd
Apr 10

WordPress – Create an instant link to Wikipedia



closeThis post was written 1 year 9 months 22 days days old, so is a bit old now. Feel free to read and comment on this post, just remember some things change with time and any facts in this post may not be accurate anymore.

I’m often wanting to create quick and useful links to Wikipedia. Obviously, you could add a link manually each time, but wouldn’t an automated system be so much better?

Well, crack open your functions.php file within your theme folder and added the following code…

add_shortcode('wikilink','add_wikilink');
function add_wikilink($paras="",$content="") {
    return '<a href="http://en.wikipedia.org/wiki/'.str_replace(" ","_",$content).'" title="Look up '.$content.' on Wikipedia" title="Look up '.$content.' on Wikipedia" target="_blank" rel="notarget">'.$content.'</a>';
}

Then, simply add the shortcode [wikilink] around any word/words that you wish to look up on Wikipedia.

For example….

The [wikilink]HTC Hero[/wikilink] runs the [wikilink]Android operating system[/wikilink].

This would then produce the following output…

The HTC Hero runs the Android operating system.

The links open in new windows (i.e. target=_blank) and I’ve set rel=nofollow – obviously you can change the above code to modify any of this.

Delicious Digg Facebook LinkedIn Read It Later reddit StumbleUpon Twitter SeparatorEmail Google Translate PDF Online Print Friendly

1 Comment

  1. Rob says:

    Awesome tip, just added it to my blog. The only downside is being careful you don’t link a piece of text that doesn’t have a wikipedia article! Really handy though.

No Pingbacks/Trackbacks

    Leave a Comment

    All comments are approved manually. No spam please, or comments that add nothing to the conversation.

    Your email address will not be published. Required fields are marked *

    *

    You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>