Your newly installed theme may not have a Print this button. The good news is that adding a Print button to your Blog posts is very easy. In this short tutorial, we’ll learn how to add a print button to blog posts.

print wp

Users can also print directly via browser and also from keyboard shortcut (Ctrl + P). But not all users/visitors are tech savvy and they may not know how to do this. Therefore a good idea is to manually place a print button in your blog posts.

How to Add a Print Button to WordPress

For this purpose, we’ll need to edit single.php file. Place the below code wherever you wish to display the print option.

<a href="javascript:window.print()">Print</a>

Instead of a plain link, you can also provide this link to a print image by using the below code:

<a href="javascript:window.print()"> 
<img src="/print.jpg" border="0"></a>

Don’t forget to provide the URL of image and upload it. This will add the print button to all posts in the blog.

You can also create a print stylesheet, so that only essential elements can be printed and unnecessary images and advertisements are omitted from the web page during print process. Create a CSS named as print.css and upload it to your theme root.

To include your print stylesheet, add the following line of code to your header.php file, within the <head> and </head> tags.

<link rel="stylesheet" type="text/css" href="<?php bloginfo('template_url'); ?>/print.css" media="print" />

Creating a print stylesheet is an optional step though but it will create a good impression on visitors as the output printed page will be styled. Your visitors will be able to print the page with a nice layout.

Leave a Reply

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