[wp-hackers] Re: print style sheets

Doug Smith doug at smithsrus.com
Sat Dec 29 16:06:12 GMT 2007

On Dec Sat, 29 Dec 2007 11:53:21 +0100, "Stephanie Booth" <bunnylists at gmail.com 
 > wrote:

> 1. Print CSS
> I noticed that WP does not provide a print stylesheet out of the box
> (I thought it used to, but I may remember incorrectly -- depends on
> the theme, I guess). Anyway, I started looking around for existing
> plugins to add a print stylesheet before writing my own. I found WP
> Print <http://wordpress.org/extend/plugins/wp-print/> but it adds a
> print link and seems a bit heavy. All I want is basically to insert
> <link rel="stylesheet" type="text/css" href="/blah/print.css"
> media="print" title="Normal" /> in the header and provide a CSS file.
> So, sub-questions:
> - is there a plugin I missed that does roughly what I want?
> - does anybody know of pre-existing print stylesheets for the  
> Sandbox theme?

I figure that if someone is capable of editing a css file, they're  
also capable of adding a line in the theme header. So why bother with  
the extra overhead of a plugin? Besides, it really is a theme specific  
issue because you are typically turning off the printing of particular  
items, and that depends on how they are constructed and named in the  

I usually just add this line to my theme header file:

<link rel="stylesheet" href="<?php echo  
get_bloginfo('stylesheet_directory'); ?>/print.css" type="text/css"  
media="print" />

Make it the last stylesheet link line so it's rules will override the  
others that come before it. Then put a print.css file in the same  
directory as the rest of the theme files and edit it as desired.

If you Google for "print style sheet" you should be able to find some  
good articles with suggestions for the kinds of things you might want  
to include in your own. For example, I like to include a rule to print  
out URLs in parenthesis after links since you can't actually click  
them on paper:

a:link:after, a:visited:after { content: " (" attr(href) ") "; }

Doug Smith <doug at smithsrus.com>

More information about the wp-hackers mailing list