WordPressを見たままプリントする方法

WordPressのページをデフォルトのままプリントしようとすると、CSSが適用されていない状態で印刷される。その回避方法をメモ。

1

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” /」

とする

2

もうひとつの方法は、印刷用のスタイルシートを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をカスタマイズ。
About Ken 327 Articles
有限会社ナセバーナルの代表取締役

Be the first to comment

Leave a Reply

Your email address will not be published.


*