Skip to content

Instantly share code, notes, and snippets.

@mypacecreator
Last active Jul 13, 2016
Embed
What would you like to do?
single.phpで、カテゴリースラッグを元にタイトル画像を表示する(子カテゴリーの場合も、自カテゴリーの画像を使う)
<h1><img src="<?php echo get_template_directory_uri(); ?>/images/title_<?php
$cat = get_the_category();
$cat = $cat[0]; {echo $cat->category_nicename;}
?>.jpg" alt="<?php echo $cat->cat_name; ?>" /></h1>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment