Feb
27
2009

ページやカテゴリーごとにCSSを変える

20:49 pm

ページやカテゴリーごとにCSSを変えるスクリプト。
前のブロックはabout ページのときに、bgabout.cssを読み込むスクリプトです。
後ろのブロックは’走る’というカテゴリーのときに、bgrun.cssを読み込むスクリプトです。
たとえば、bgrun.cssとして、’走る’というテーマに相応しい背景画像をセットするといった使い方ができます。
ランダムに背景画像を切り替えるよりクールです。

<!-- ------ BACKGROUND IMAGES BY PAGE ------ -->
<?php if (is_page('about')) { ?>
<link rel="stylesheet" href="<?php bloginfo('stylesheet_directory'); ?>/bgabout.css" type="text/css" media="all" />
<?php } ?>
<!-- ------ BACKGROUND IMAGES BY CATEGORY ------ -->
<?php if (is_category('走る')) { ?>
<link rel="stylesheet" href="<?php bloginfo('stylesheet_directory'); ?>/bgrun.css" type="text/css" media="all" />
<?php } ?>
Written by hbirds in: WPカスタマイズ | Tags: ,

No Comments »

RSS feed for comments on this post. TrackBack URL

Leave a comment

You must be logged in to post a comment.

www.hbirds.net