Creating Printer-Friendly Versions of WordPress Posts and Pages
In this tutorial, we’ll show you how to place Print This Post buttons into WordPress posts and pages. The main reason you’d want to do this is to extend a courtesy to your readers. Many of them still print things they read online and you don’t want them to waste that expensive printer ink just to print your logo and theme as well as the post.
Without this solution, you’d likely need to create a separate CSS file with styles specifically for the printed page. Fortunately, the WP-Print plugin makes this much easier. It will automatically create a printer-friendly version of each post or page.
Install WP-Print Plugin
- In your WordPress dashboard go to Plugins >> Add New:
- Type wp-print in the Keyword search box.
- Click on the Install Now button on the WP-Print plugin listing and, once it is installed, – on the Activate button.
The next step is to make these links appear on your posts/pages.
Insert Printer-Friendly Links Manually
- The most straightforward way to enable a printer-friendly version of a single WordPress blog post or page is simply to insert the [print_link] tag inside the post or page manually:
- The output (for a post) will look like this:
Enable Printer-Friendly Links Automatically
What if you would like all of your WordPress blog posts and pages have a printer-friendly version? To do this, you’ll have to get under the hood and do some coding customisation.
- Open wp-content/themes/YOUR THEME NAME/index.php (you may also open your single.php, post.php, page.php or theloop.php files, if they exist in your theme).
1 Find the following code:
while (have_posts() ) : the_post();
2 Add anywhere below It:
if(function_exists('wp_print')) { print_link(); }
- The first value is the text for printing post.
- The second value is the text for printing page.
- In your posts front end list, at the top of every post heading, you will now see the Pint This Post link with a small printer icon:
- If you would like to change the Print This Post text to your own liking, go to Settings >> Print:
- You will see the Print Options admin page. Enter you own text into the Print Test Link for Post and Print Text Link for Page fields:
Final Step – Regenerate Your Blog Permalinks
For all the above changes to work, you need to regenerate your blog permalinks.
- In your WordPress dashboard go to Settings >> Permalinks and simply click on the Save Changes button:
- Now go to your blog front end and click on the Print This Post link for one of the listed posts. You will now see the printer-friendly version of the post, with the Click here to print link:
Hiding Some Text from Printing
In some situations, you may wish to hide some text in a post or page from printing.
- Place such text between the [donotprint] and [/donotprint] tags. It won’t get displayed for the post or page printer friendly versions.
- However, it will still be displayed as normal on a normal post or page view.
- Do note that if you are using WP-Email, any text within [donotprint] and [/donotprint] tags will not be emailed.
{snippet subscribe-video-club-ad}
When I click on the Print-Friendly link I put on one of my articles, it goes to a very ugly page that has way too much information about every link on that page. If I click on the little print icon that shows up on that ugly page, it takes me to the wording of my article on [url=http://printfriendly.com]printfriendly.com[/url] where I can click and print. Is that how it’s supposed to work? I think it would confuse my users.
Nicely explained
But using this shortcode and plugin it gives print of the the code not designing part.
if you use this for post then it shows code of single.php file which is available in wordpress current theme folder.
Hi Mahen.
Apology, but in our tutorial we missed important point on regenerating permalinks. I added it now, so please read the post once again to get the whole picture this time.
In my testing, I was able to see the print-only version of my post only after I went to Settings -> Permalinks and clicked on Save Changes.
Hope this will help you too.
Regards,
Alex
I have one specific page on my site I am trying to get to print without anything around it (the menu, logo, footer, etc.). I installed the plugin, did all of your steps, have the print page logo and link. When clicked it opens the page on another screen correctly, but it still includes the url of my site, the name of the page at the top (even though I’ve hidden it), Posted by.. the date, time, etc. In in Settings, Print, I’ve put all the options to No. I don’t see anyplace else to get rid of this text. Is this possible? I would like it to just print cleanly the contents of my page with nothing else around it. Thanks!
Thank you for the guidance.
Thanks for sharing this article .