Support » Themes and Templates » Printer Friendly pages

  • Resolved papadoc

    (@papadoc)


    Can anyone tell me how the syntax works for setting a different CSS sheet in WP?

    I’ve managed to make it work in local webpages on my machine, but I think there’s something screwy going on with the way WP pulls in pages, and I’m not quite so clear on how the code works in the HEAD.

    My website is http://www.nixsight.net
    The current code collecting the stylesheet is, as lifted from “connections”:
    <style type="text/css" media="screen">@import url( <?php bloginfo('stylesheet_url'); ?> ); </style>

Viewing 13 replies - 1 through 13 (of 13 total)
  • Mark (podz)

    (@podz)

    Support Maven

    Back in the olden days of 1.2.2 and before, we used this in the header:
    ` <link rel=”stylesheet” type=”text/css” media=”print” href=”<?php echo get_settings(‘siteurl’); ?>/print.css” />

    Would that help if you wrote the print.css ?

    What’s wrong with:

    <link rel="stylesheet" href="/wp-content/themes/default/print.css" type="text/css" media="print" />

    … in the header file?

    Added: looked again at Podz’s suggestion… yes, I see what you mean. Same thing, but for a template.

    I prefer:

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

    since it uses the current active theme directory. But this is (of course) dependent on keeping print.css with the other theme templates.

    Looking into the website’s source code after putting each of those in would seem to show that they’re doing what they need to be doing, but unfortunately it’s not working when I go to print the page.

    Do I need to change something else on the page? At the moment, the following bit of code is still intact in the header:
    <style type="text/css" media="screen">@import url( <?php bloginfo('stylesheet_url'); ?> );
    </style>

    And I’ve been putting your suggested bits of code with the other <link rel=... coding that’s there.

    So the whole thing looks like this:
    <meta name="generator" content="WordPress <?php bloginfo('version'); ?>" /><!-- leave this for stats please -->

    <style type="text/css" media="screen"> @import url( <?php bloginfo('stylesheet_url'); ?> );
    </style>

    <link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="<?php bloginfo('rss2_url'); ?>" />
    <link rel="alternate" type="application/atom+xml" title="Atom 0.3" href="<?php bloginfo('atom_url'); ?>" />
    <link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />

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

    <?php wp_get_archives('type=monthly&format=link'); ?>
    <?php wp_head(); ?>
    </head>

    But as I don’t really understand what the code is doing, I know I’m probably putting it in completely the wrong place, or not making some fundamental important change that’s needed. I’ve always relied on Dreamweaver to do the stylesheet attaching, I’m ashamed to admit.

    First things first: do you actually have a print.css file?

    Tut, yes… what do I look like, an amateu… actually, scratch that.

    But yeh, there’s a really stripped down CSS file in there, named “Print.css”… just pretty much takes out everything but the main content.

    Is that Print.css or print.css? capital letters will be affected.

    Good point. All changed to lower-case now… but still not working! Although that would have been a bonehead typical error on my part!

    When looking at the source of your front page I see this:

    <link rel="stylesheet" href="/wp-content/themes/default/print.css" type="text/css" media="print" />

    Which does not exist, and it seems you want this:

    <link rel="stylesheet" href="/wp-content/themes/no_game_plan/print.css" type="text/css" media="print" />

    So may I again recommend using:

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

    Which, if the print.css is with the theme, clears up any mistakes.

    I don’t see /wp-content/themes/default/print.css on your site.

    I use WP-Print by GaMerZ (aka Lester Chan of Singapore). I tried to write the Print CSS but it was just a pain. GaMerZ created a great plugin that is easy to customize. I would recommend checking this out if you want printer friendly pages.

    WP-Print can be downloaded from here:
    http://www.lesterchan.net/portfolio/programming.php

    pcmt said: “I don’t see /wp-content/themes/default/print.css on your site.”

    Yeh, this is me not looking at the files properly and forgetting that the default theme isn’t the one I’m using.

    Kafkaesqui had it with his last suggestion… thanks for all your insights, guys…

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Printer Friendly pages’ is closed to new replies.