0Dell 3130CN LogoAdding a print icon to print individual blog posts

In addi­tion to this blog I also have a blog about recipes.  I decided that I wanted a print icon on the main page for each post so that people can print the recipes.  Googling provided vari­ous sug­ges­tions, none of which worked.  How­ever, I even­tu­ally cobbled togeth­er the fol­low­ing, which seems to work…

Edit the code of your blog and find the code

<!-- email post links -->

Above that put the fol­low­ing…

&lt;script&gt;
function printPost(postUrl)
{
doPrint = true;
var pw = window.open(postUrl);
}
if(opener.doPrint == true)
{
window.print();
window.onfocus = function() { window.close(); }
}
&lt;/script&gt;

&lt;a expr:href='&quot;javascript:printPost(&quot; + &quot;&quot;&quot; + data:post.url + &quot;&quot;&quot; +  &quot;);&quot;'&gt;&lt;img src='http://siteresources.worldbank.org/images/Print_plain.gif'/&gt;&lt;/a&gt;

And you’re done!

Cred­it in vari­ous parts goes to…
Con­sum­ing Exper­i­ence
Blog­ger Plu­gins
Sharkyso­ft

Found this useful? Please do let us know by dropping a comment below. If you would like to subscribe please use the subscribe link on the menu at the top right. You can also share this with your friends by using the social links below. Cheers.

Leave a Reply