Skip to content

Instantly share code, notes, and snippets.

@mypacecreator
Created July 2, 2014 17:47
Embed
What would you like to do?
アーカイプページで、カテゴリースラッグを元にタイトル画像を表示する(子カテゴリーの場合、自カテゴリーの画像を使う)
<?php if(is_category()): ?>
<h1><img src="<?php echo get_template_directory_uri(); ?>/images/title_<?php
$cat_id = get_query_var('cat');
$cat = get_category($cat_id);
echo $cat->category_nicename;
?>.jpg" alt="<?php single_cat_title(); ?>" /></h1>
<?php endif; ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment