I have used WordPress to create a recipe site. The recipes are, of course, simply posts in a specific category. What I would like to do is this:
When a user selects a post in a category, I would like to find a way to allow the user to print out that recipe. I tried using the Javascript window.print() but that prints the entire screen. I only want the recipe (post) printed. Can anyone suggest a way to do this?
Any help much appreciated.
Thanks
MathSmath
Member
Posted 1 year ago #
You can specify a separate stylesheet for print, and use it to hide any elements you don't want to, um, print. The basic trick is this: in addition to your regular stylesheet, link a print-specific stylesheet like so
<link rel="stylesheet" type="text/css" media="print" href="print.css" />
There is a great primer on print stylesheets over at A List Apart.
EDIT: This stylesheet will kick in whenever the print function is triggered--whether by window.print, or by a user selecting file->print.