WordPress shortcodes for DOIs and other research links
I’ve written a plugin for WordPress that adds shortcodes to link to research. To use it you’ll need a self-installed WordPress blog. A blog at wordpress.com won’t be able to use it.
[doi id=“10.1093/aob/mct148”]link text[/doi] links the link text to http://dx.doi.org/10.1093/aob/mct148 It also does a few more things.
If there are research codes used, the blog checks to see if it has citations stored for them. If it does then it outputs a References section at the end of the post. It’s not in this post, because I’m not actually using the shortcode in this post.
If there isn’t a citation stored, the blog will go through each DOI and make one. It’s designed to make citations compatible with the ScienceSeeker website. If you’re a science blogger then you would do well to sign up to this.
It solves a problem with altmetrics too.
At AoB Blog we post about various papers, usually from Annals of Botany or AoB PLANTS. If people like what they see and tweet a link to the post, the post gets credit for the link, but the original paper doesn’t. It wasn’t the original paper tweeted, it was the post. I’ve talked with people at OUP and Altmetric.com and the answer we settled on was to add a meta tag in the header.
<meta name=“DCTERMS.isBasedOn” scheme=“DCTERMS.URI” content=“http://dx.doi.org/10.1093/aob/mct148”/>
This gives a way to connect a post to the paper it’s commenting on. It only works from the second time a page is loaded, but the first is usually a preview by the author, so that’s not critical.
Not everything people want to link to has a DOI. What do you do if you have a mix of DOI and http:// links and you want to use them in the same reference section? There is a url shortcode.
[url id=“http://aobblog.com/2013/08/brachypodium-is-not-arabidopsis/” author=“Chaffey, N.” date=“2013” title=“Brachypodium is NOT Arabidopsis(!)” website=“AoB Blog”]
…will output a citation in a similar style to the DOI citation, with a ‘date accessed’ note added, set to whenever you first run the shortcode. If you don’t specify a publication date then it sets this year. If you don’t specify an author then it is set to ‘Unknown’.
You can download the code from Dropbox and install it, or have a laugh the at code. The code is not sleek, because I wanted to see what was happening each step of the way. As a warning, I don’t know if this is secure code or not. That’s not likely to be a big problem if it’s just you on your site, but it’s an issue if you have a multi-author blog.
Also it doesn’t handle a few other things yet. There is a space for an [arxiv] shortcode. I haven’t added this yet because arxiv outputs metadata in a different way to dx.doi.org. Despite having DOIs, Figshare doesn’t work with it either. I don’t know why Figshare out their DOIs in a different way, because I haven’t spoken to them yet. There’s probably a good reason, so that might mean making a [figshare] shortcode to handle those links.
At the moment the code is up for discussion. Once I’ve understood this page and added arxiv and figshare support then I’ll see about adding it to the WordPress plugin repository.
Update: Thanks to Stack Overflow I now know how to get data for an ISBN, so an [isbn] shortcode will be possible too.