Creating Printer-friendly Versions of WordPress Posts

In this tutorial we’ll show you how to place add “Print This Post” button to WordPress. The main reason you’d want do this is as a courtesy for your readers. Many 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.

This is a themed tutorial because our sister newsletter with Drupal tutorials is covering the same topic this week: Creating Printer-friendly Versions of Drupal Articles.

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.

How to Add Printer-friendly Versions of Your WordPress Posts

  • Step 1: Click here to download the latest version of “WP-Print”. Click the orange “Download” button in the top-right corner..
  • Step 2: Extract the files into a folder on your desktop. The folder will be called, unsurprisingly “wp-print”
  • Step 3: Login to your site’s files via FTP and navigate to /wp-content/plugins/.
  • Step 4: Upload the “wp-print” folder to  /wp-content/plugins/.
  • Step 5: Go to wp-admin >> Plugins and click “Activate” under “WP-Print”
  • Activate WP Print

The next step is to make these links appear on your posts:

Enabling the Printer-friendly Links – Easy

The most straightforward way to enable the Printer-friendly Version is simply to add this to each post anywhere you like: [print_link]

The output will look like this:

Wordpress Printer-friendly Version

Enabling the Printer-friendly Links – Code

If you’re feeling confident with your ability to edit WordPress themes files there are instructions from the developer at LesterChan.net (click the usage tab) on how to modify your theme to automatically include the print button on every post:

  1. Open wp-content/themes/<YOUR THEME NAME>/index.php

    You may place it in single.php, post.php, page.php or theloop.php also.

  2. Find:

    <?php while (have_posts()) : the_post(); ?>

  3. Add Anywhere Below It:

    <?php if(function_exists(‘wp_print’)) { print_link(); } ?>

    If you DO NOT want the print link to appear in every post/page, DO NOT use the code above. Just type in [print_link] into the selected post/page content and it will embed the print link into that post/page only.

    The first value is the text for printing post.

    The second value is the text for printing page.

    Default: print_link(”, ”)

    Alternatively, you can set the text in ‘WP-Admin -> Settings -> Print’.

  4. Go to ‘WP-Admin -> Settings -> Print’ to configure the style of the print text link.
Note
  • If you do not want to print a portion of your post’s content, do the following:

    [donotprint]Text within this tag will not be displayed when printing[/donotprint]

    The text within [donotprint][/donotprint] will not be displayed when you are viewing a printer friendly version of a post or page.

    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][/donotprint] will not be emailed as well.

  • WP-Print will load ‘print-css.css‘, ‘print-posts.php‘ and ‘print-comments.php‘ from your theme’s directory if it exists.
    • If it doesn’t exists, it will just load the respective defalult file that comes with WP-Print.
    • This will allow you to upgrade WP-Print without worrying about overwriting your printing styles or templates that you have created.

Click here to read the original tutorial on Open Source Training.

{loadposition wordpressnewsletter}

Leave a Reply

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