Forums

Printing a post (2 posts)

  1. douffle
    Member
    Posted 1 year ago #

    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

  2. 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.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags