WP Print Friendly  for

Extends WordPress’ template system to support printer-friendly templates for posts, pages, and custom post types. Uses WP standard template naming to support templates on a post-type basis. Supports printing paged posts on single page. Adds nice URLs for printer-friendly pages.

The plugin comes bundled with a basic print template that will likely suit many needs.

To take advantage of its templating capabilities, add a file named wpf.php to your theme. From there, you can use any existing WordPress functions to generate your print view. To create a custom print template for your homepage, add wpf-home.php to your theme. From there, standard WordPress template naming conventions are followed, so wpf-[custom post type name].php or wpf-[custom taxonomy name].php would be invoked for your custom post type and custom taxonomy, respectively.

To add a print link to your templates, you can either let the plugin add it automatically via the settings available under Options > WP Print Friendly, or you can use this function: wpf_the_print_link( $page_link, $link_text, $class, $page_link_separator, $page_link_text );. The optional parameters are as follows:

  • $page_link: Set to true to include a link to the current page of a paged post. To exclude this link, set to false.
  • $link_text: Sets the text for the print link for the post’s full content. Defaults to “Print this post.”
  • $class: CSS class for the print links. Defaults to “print_link.”
  • $page_link_separator: Specifies how the full-post and page-specific print links should be separated. Defaults to ” | “.
  • $page_link_text: Sets the text for the page-specific print link. Defaults to “Print this page.”
  • $link_target: If set to “new”, print links will open in a new window.

106 Thoughts Contributed to “WP Print Friendly”

  1. Emil - May 25, 2011 at 6:14 pm Reply

    Hi,

    Is there a way to replace text button to an printer image with your plugin?

    • Erick Hitter
      Erick Hitter - May 27, 2011 at 11:11 am

      Emil,

      The plugin doesn’t have that feature built in, but with an icon and a bit of CSS, it can easily be added. I’ll consider adding that capability to a future version of the plugin.

      Erick

    • Tom - June 27, 2012 at 5:20 pm

      It would also be cool to have justification options, so that the link or icon could be left, right or center…. I tend to look to the right for that stuff, and it is on the left, where I kind of lose it in the clutter.

  2. Veggie Belly - May 28, 2011 at 8:22 pm Reply

    I downloaded the plugin and installed. Now when I click on the print link, Im getting a 404. What am I doing wrong? Thanks for your help!

    • Erick Hitter
      Erick Hitter - May 31, 2011 at 9:41 am

      After activating the plugin, did you refresh your permalinks by going to Settings > Permalinks and clicking the Save Changes button? If not, you need to do so.

      If you’ve done that, can you provide more information about where you’re encountering the 404 error? Does it happen only for certain content (posts, pages, just the homepage, etc) or in certain areas of the site?

  3. Gabi - June 2, 2011 at 2:33 pm Reply

    Hi, Erick – “use this function” is a little bit too complicated for WP newbies ;-) How do I use it – could you give the complete code please? Do I have to put in in some brackets like a shortcode? Does it work in pages, articles and/or temlates? And will your plugin print the content of custom fields?

    Thanks for any help – many greetings, Gabi

    • Erick Hitter
      Erick Hitter - June 2, 2011 at 7:58 pm

      Gabi,

      You would place the code in your theme files. For example, if you need just a basic print link, you can add <?php wpf_the_print_link(); ?> to your theme’s loop to add print links for each post in the loop. If you needed to change the default link text to read Print this article, you would add <?php wpf_the_print_link( false, 'Print this article' ); ?>. If you have paged posts in your WordPress instance and would like print links for each page of the paged post, you would add <?php wpf_the_print_link( true ); ?>.

      Hope this helps,
      Erick

  4. Gabi - June 3, 2011 at 7:40 am Reply

    Hi, Erick – thanx for your quick answer! Unfortunatly the code does not work – I get “Fatal error: Call to undefined function wp_the_print_link()” when I add it to single.php… Automatic insertion works, though – but I specifically want to put the print link within a special meta box of my blog…

    I also noticed that the plugin doesn’t print custom fields that belong to posts.. Is there maybe a way to change that?

    Greetings and thanx in advance for any assistance – Gabi

  5. Gabi - June 3, 2011 at 7:47 am Reply

    Found the first answer myself : It’s NOT wp_the_print_link – the name of the funktion should be wpf_the_print_link ;-) Still searching how to include the content of custom fields and how to open the print version in a new tab/window, though…

    Many greetings – Gabi

    • Erick Hitter
      Erick Hitter - June 3, 2011 at 9:52 am

      Gabi,

      I’ve updated the documentation to reflect the correct function name. Whenever you add plugin functions to your theme, it’s always a good idea to include a function_exists check to ensure that if, either intentionally or accidentally, a plugin is disabled, your site continues to function. Simply adding if( function_exists( 'wpf_the_print_link' ) ) before the reference to the print function should do the trick.

      To include post meta, you’ll need to create your own print template in your theme. You can use the default-template.php file included with the plugin as a starting point. You should copy that file into your theme and rename it wpf.php. After doing so, the plugin will load that file when rendering print-friendly views, rather than the default template. You can then add the necessary post meta.

      Erick

  6. Gabi - June 3, 2011 at 12:30 pm Reply

    Thanx, Erick – I did create my own wpf-php and it works fine.

    One last question though: How do I open the print file in a new tab or window, so that the regular blog does not disappear? If the print version replaces the regular view users will have to use the browser’s back-button to continue reading my blog which is awkward…

    Many greetings – Gabi

    • Erick Hitter
      Erick Hitter - June 6, 2011 at 9:07 am

      Currently, that isn’t an option using the wpf_the_print_link function. I’ve noted the suggestion and will include that in a future release. In the meantime, and if you’re feeling a bit adventurous, you can build your own print link using the function wpf_get_print_url(). If used within the loop, no parameters are needed; the function simply returns the URL for the print-friendly version of the current post within the loop. If used outside of the loop, the first argument should be set to the post ID.

      Erick

    • Gabi - June 8, 2011 at 4:00 am

      Sorry to bother you again, Erick – but I don’t know any PHP :-( When I construct a link like

      <a href="” target=”_blank”>Open print version in new window

      within the loop (single.php) it opens the REGULAR page in a new window. I noticed that the >>&print=all<< part is missing, but when I add it like this

      <a href="&print=all” target=”_blank”>Open Print version in new window

      the URL part (?p=123) disappears. So I still can’t open the print version in a new window. What’s wrong with my sorry attempt to code PHP?

      Greetings from Germany – Gabi

    • Gabi - June 8, 2011 at 4:02 am

      Sorry to bother you again, Erick – but I don’t know any PHP :-( When I construct a link like

      <a href="" target="_blank">Open print version in new window

      within the loop (single.php) it opens the REGULAR page in a new window. I noticed that the >>&print=all<< part is missing, but when I add it like this

      <a href="&print=all" target="_blank">Open Print version in new window

      the URL part (?p=123) disappears. So I still can’t open the print version in a new window. What’s wrong with my sorry attempt to code PHP?

      Greetings from Germany – Gabi

  7. Gabi - June 8, 2011 at 4:07 am Reply

    Oh dear – the code parts disappear. Another try:

    The first link looks like this (without the stars, of course)
    *<*a*href=*"**target=”_blank”*>*Open print version in new window*

    The second part like this:
    *<*a*href=*"**?*print*=*all” *target=”_blank”*>*Open Print version in new window**

    • Erick Hitter
      Erick Hitter - June 8, 2011 at 1:21 pm

      Gabi,

      Version 0.3.2, which should be available within the hour, adds an option to open print links in a new window. To do so, the final argument for wpf_the_print_link should be set to new. Omitting the argument will cause the print view to open in the same window.

      Erick

  8. firegnom - June 8, 2011 at 11:02 am Reply

    Hi ,
    I have website with subpages like /page1/page2
    your plugin works on /page1/print but unfortunately doesn’t work on /page1/page2/print , i think problem lies in rewrite rules which don’t take in to consideration that something might be before “slug”,. Would be glad if you could help maybe i am doing something wrong (btw yes i did click on save changes ;) ).

    thx

    • Erick Hitter
      Erick Hitter - June 27, 2011 at 8:10 pm

      Firegnom,

      I’m working on a solution to this problem and hope to release an update in the very near future. Thanks for reporting this problem.

      Erick

  9. Gabi - June 8, 2011 at 1:58 pm Reply

    Wow – great service, thank you!

  10. sateesh - June 20, 2011 at 1:56 am Reply

    Hi,
    I have a requirement like to print the content of post only. Is there any chance to do it. I have impressed by you plugin. But Its not reached to my requirement. Could you please help me out.

    • Erick Hitter
      Erick Hitter - June 20, 2011 at 10:48 am

      Sateesh,

      You can include a custom print template in your site’s theme and modify it to fit your needs. I suggest starting by copying the default print template from the plugin folder to your theme directory, renaming the file wpf.php, and modifying it as needed.

      Erick

  11. Poxy - June 20, 2011 at 10:40 pm Reply

    This plugin doesn’t seem to work for pages which are not @ root level. If there is a page with a parent, it won’t open the print preview for it.

    • Erick Hitter
      Erick Hitter - June 27, 2011 at 8:10 pm

      Poxy,

      I’m working on a solution to this problem and hope to release an update in the very near future. Thanks for reporting this problem.

      Erick

  12. Gabi - June 21, 2011 at 12:28 pm Reply

    Hi, Erick – after I activated permalinks within my blog, I get 404-errors when trying to print pages and articles (it did work before). I de-activated wp print friendly, activated it again and hit “save changes” on the permalinks page – to no avail. What elso could I try?

    I’m using the variable wpftheprintlink within single.php and the generated print link looks something like http://www.my-domain.de/name-of-article/print – is something wrong with that?

    Greetings from Germany – Gabi

    • Erick Hitter
      Erick Hitter - August 13, 2011 at 7:59 pm

      Gabi,

      Version 0.4 should fix this problem.

      Erick

  13. Art - June 28, 2011 at 11:42 am Reply

    Erick,

    I think I’ve found another corner case in which Print Friendly fails.

    I’m using a really neat plug-in named embed, a tool that lets you display several “child” posts together within either a page or a “parent” post (davidtyler.we.bs/page/web/wordpress-plugin-embedded-posts).

    When a composite page with embedded posts is displayed, the PF link displays a clone of the page with all page and browser furniture, not the PF version.

    Cheers,
    Art

    • Erick Hitter
      Erick Hitter - August 13, 2011 at 7:59 pm

      Art,

      Version 0.4 may correct this problem, but it’s also possible that you’ll need a custom template for use with this plugin. What is the name of the plugin you’re using?

      Erick

  14. Chris - July 7, 2011 at 1:52 pm Reply

    I have a client that was about to purchase your ad-free version however we are running in to some cross-browser compatibility issues. If you can respond via email, I would like to link you to the site to review a sporadic issue between certain posts. Thank you!

  15. Marissa - July 8, 2011 at 5:55 pm Reply

    Thanks for the plugin! Question though, and please excuse me being a complete newbie who doesn’t know much about coding. I was able to add a print option, but when i tried it, it doesn’t let me print individual posts, it only lets you print it as one long page – is there a way to separate it so people could print each individual post? Hope that makes sense. If you look at my site you will see what I mean. Thanks!

    • Brian - August 5, 2011 at 10:16 am

      I have this issue too. “Print this entry” and “Print this page” print all ten entries on each page. If I open a single post then it only prints that entry, like it should. Would love a fix for this. Thanks!

    • Erick Hitter
      Erick Hitter - August 13, 2011 at 7:57 pm

      Version 0.4 fixes this problem.

      Erick

  16. Mark - July 12, 2011 at 1:54 am Reply

    hi i need help. the plugin works… but not really. i cant seem to limit the plugin to just appear on post pages. i uncheck the “display automatically on pages” box but they still appear on both pages and posts. thanks in advance for your help

    • Erick Hitter
      Erick Hitter - August 13, 2011 at 7:57 pm

      Mark,

      Version 0.4.1 fixes this problem.

      Erick

  17. Gosunkugi - July 14, 2011 at 2:06 pm Reply

    GREAT WORK! Mr. Erick that’s exactly I needed. But, still have the same issue, with page1/page2… Mr Erick or some of the users get solved? Please give us a light about! thanks ^_^

    • Erick Hitter
      Erick Hitter - August 13, 2011 at 7:40 pm

      Version 0.4 adds full support for pages, namely child pages.

      Erick

  18. Dan - July 21, 2011 at 11:12 am Reply

    Hey Erick,

    First of all – awesome plug-in! The functionality and method you used is exactly what I’m looking to plug in to my current project. I’m having a small problem though: using a custom post type, the rewrite rules and link generation work like a charm, but the /post-type/post-name/print url doesn’t seem to be calling the wpf-post_type.php template at all. I’ve crawled over the code a bit, and can’t immediately find why this should be. Any ideas?

    Thanks!

    • Erick Hitter
      Erick Hitter - August 13, 2011 at 8:46 pm

      Dan,

      If version 0.4 doesn’t fix this problem, please let me know.

      Erick

  19. Harold - July 22, 2011 at 4:59 pm Reply

    “To take advantage of its templating capabilities,” you write, “add a file named wpf.php to your theme. From there, you can use any existing WordPress functions to generate your print view. To create a custom print template for your homepage, add wpf-home.php to your theme.”

    I am using WordPress and I am completely lost here. I have checked and have found “WP Print Friendly is activated.” When I go to settings to find “Options,” there is no sub heading. Now, I’m really confused. I doubt if I need to say that I am a novice user (smile). I just want my blog viewers to be able to print a recipe from my site.

    • Erick Hitter
      Erick Hitter - August 13, 2011 at 8:17 pm

      Harold,

      Version 0.4 fixes numerous bugs, so I’d start by upgrading to that.

      After doing so, go to Settings > WP Print Friendly and make sure that Automatically add print links based on settings below? is set to Yes. If you are using a plugin to create your recipes, you may need to check additional options under Display automatically on for my plugin to interact with the recipes plugin. Otherwise, if you’re using posts or pages, ensure that those options are selected under Display automatically on.

      Erick

  20. Abdulrahman Nahhas - July 28, 2011 at 4:37 am Reply

    thank you for this plugin but I would ask a question about target frame in hyperlinks. now every think is ok bu the print page is open in the same page. in settings panel I select new page it doesnt change anything.

    how we can make it manually.? it is so important for me can you help me…

    • Erick Hitter
      Erick Hitter - August 13, 2011 at 8:24 pm

      Version 0.4 should fix many problems with the print links themselves.

      I’ll note your request for popup print windows for a future version; the drawback to them is that many browsers will block them without prior approval.

      Erick

What do you think?

(required)

Oomph is a full-service digital agency providing strategy, design & development and a host of other web services. A leader in WordPress and Drupal implementation, Oomph pushes the boundaries of today’s web platforms. Oomph has a diverse portfolio of non-profits, international corporations and publications. Team Oomph is always thinking creatively about the digital world. Oomph is located in Providence and Boston.