カテゴリーごと、画像を表示したい
-
お世話になります。
テーマは、WSC 4.3を使用しております。カテゴリーごと、投稿一覧の上に画像を表示したいのですが、
うまく表示することができません。。。現在、以下のように、スラッグごとに指定をしています。
div.category1 #main_img{ width: 400px; height:150px; background-image: url(img/top.gif); background-repeat: no-repeat;} div.category2 #main_img{ width: 400px; height:150px; background-image: url(img/category1.gif); background-repeat: no-repeat;} div.category3 #main_img{ width: 400px; height:150px; background-image: url(img/category2.gif); background-repeat: no-repeat;}
↑こんな感じにstyle.cssに各カテゴリーの画像を指定して
<div id="content"<?php if (is_category()) { ?> class="<?php $cat = get_the_category(); $cat = $cat[0];{echo $cat->category_nicename;} ?>"<?php } ?>> <?php $post = $posts[0]; // Hack. Set $post so that the_date() works. ?> <?php /* If this is a category archive */ if (is_category()) { ?> <h2 class="pagename"><?php single_cat_title(); ?></h2> <div id="main_img"><img src="http://xxx/xxx/wp-content/themes/wsc4_3/img/spacer.gif" width="600px" height="150px" /></div> <?php /* If this is a tag archive */ } elseif( is_tag() ) { ?> <h2 class="pagename">‘<?php single_tag_title(); ?>’ タグ</h2>
↑archive.phpでこのように設定しています。
(spacer.gifは画像スペースをとるために透明の画像を配置してます)この方法でカテゴリー別に画像を表示することはできたのですが、
カテゴリーの編集で親カテゴリーを指定した際に、
親カテゴリーに子カテゴリーに指定している画像が表示されてしまいます。
親カテゴリーに表示されている画像を消すにはどうすればいいでしょうか?回答よろしくお願いします。
4件の返信を表示中 - 1 - 4件目 (全4件中)
4件の返信を表示中 - 1 - 4件目 (全4件中)
- トピック「カテゴリーごと、画像を表示したい」には新たに返信することはできません。