WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Printer Friendly pages (14 posts)

  1. papadoc
    Member
    Posted 8 years ago #

    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>

  2. Mark (podz)
    Support Maven
    Posted 8 years ago #

    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 ?

  3. pcmt
    Member
    Posted 8 years ago #

    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.

  4. Kafkaesqui

    Posted 8 years ago #

    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.

  5. papadoc
    Member
    Posted 8 years ago #

    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.

  6. Kafkaesqui

    Posted 8 years ago #

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

  7. papadoc
    Member
    Posted 8 years ago #

    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.

  8. katie1
    Member
    Posted 8 years ago #

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

  9. papadoc
    Member
    Posted 8 years ago #

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

  10. Kafkaesqui

    Posted 8 years ago #

    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.

  11. pcmt
    Member
    Posted 8 years ago #

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

  12. jbsprague
    Member
    Posted 8 years ago #

    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

  13. papadoc
    Member
    Posted 8 years ago #

    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.

  14. papadoc
    Member
    Posted 8 years ago #

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

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags