0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Welcartでカテゴリーごとにバナーを切り替える

Posted at

WelcartBasicの子テーマを使ってカスタマイズの備忘録。
子テーマを作成後親テーマからコピペしたcategory.phpを編集します。

category.php
<header class="page-header">
	<?php
    the_archive_title('<h1 class="page-title">', '</h1>');
    the_archive_description('<div class="taxonomy-description">', '</div>');
    ?>
</header> <!-- .page-header -->

ここを書き換えてきます。(画像は本家welcartBasicの公式デモより)
image.png

category.php
<?php
$cat = get_category( $cat );
$catslug = $cat->slug;
?>
<div id="cat_img">
	<img src="<?php echo get_stylesheet_directory_uri() ?>/img/category/<?php echo $catslug; ?>.jpg" alt="<?php single_cat_title(); ?>">
</div>

子テーマにimgというフォルダに更にcategoryというフォルダを作る。
(カテゴリーのスラッグと同じ名前).jpgという画像を入れると反映されます。
スラッグが分からなかったらダッシュボードからカテゴリーで確認しましょう。

image.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?