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

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をカスタマイズ。

About Ken 327 Articles
有限会社ナセバーナルの代表取締役

Be the first to comment

Leave a Reply

Your email address will not be published.


*