WordPressのページをそのままプリントしようとすると、CSSが適用されていない状態で印刷される。
WPの外観>テーマ編集の「header.php」を
<link rel=”stylesheet” href=”<?php bloginfo(‘stylesheet_url’); ?>” type=”text/css” media=”screen, projection” />
に「, print」を追加し
<link rel=”stylesheet” href=”<?php bloginfo(‘stylesheet_url’); ?>” type=”text/css” media=”screen, projection, print” />
とする
もうひとつの方法は、印刷用のスタイルシートをstyle.cssからまるごとコピーしてリンクさせる。
style.cssをコピーしprint.cssにリネーム
header.phpの
<link rel=”stylesheet” type=”text/css” media=”screen” href=”<?php bloginfo(‘stylesheet_url’); ?>” /」
の下に
<link rel=”stylesheet” type=”text/css” media=”print” href=”<?php bloginfo(‘template_directory’); ?>/styles/print.css” /」
を追加
あとは、サイドバーなど印刷に邪魔なものをdisplay: none;で非表示にするなどprint.cssをカスタマイズ。
![wordpress-logo-stacked-rgb[1]](https://i0.wp.com/www.nase.co.jp/wp-content/uploads/2011/02/wordpress-logo-stacked-rgb12-300x186.png?resize=300%2C186)
Leave a Reply