WordPress: Stopping the Sidebar from Printing

I’ve already blogged about this, but here’s a new method on how to fix the problem. This one doesn’t bloat the site as much, and keeps the css files down to a minimum.

Please note: I’m assuming you still use the default theme. Things will be slightly different with other themes, but in general the same principal should apply.

In the file header.php remove media=”screen” from the following line:

<link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />

In style.css, just before the line

/* Begin Typography &amp; Colors */


@media screen {

At the bottom of the file add the following line:

@media print {
    /* style sheet for print goes here */  
   #sidebar { display: none; }

Bingo no wasted paper from printing the side bar.

August 14, 2009 · robert · Comments Closed
Posted in: Howtos, WordPress