How to: Add a “Print” button to your posts

Even if this is not a good practice, printing webpages is common for many internet users. If you’re interested in adding a “Print this” button to your posts, just read this recipe, which also include some info about creating a nice print stylesheet.

If you don't know how to create a great print stylesheet, you should definitely read this tutorial.

To include your print stylesheet, add the following line 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" />

Now we have to create our "Print this" button. Open your single.php file and add the following line:

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

Good job! Your visitors are now able to print your posts easily with a nice print styling.

Leave a Comment

* Name, Email, Comment are Required