サムネイル画像を表示する
公開日:2014年10月25日
更新日:2014年10月26日
WordPressでサムネイル画像を表示する。
void the_post_thumbnail( [ mixed $size = ‘post-thumbnail’ [ , mixed $attr = ” ] ] )
- $size
- サイズ指定 省略時:’post-thumbnail’で指定した値
- $attr
- 属性を文字列または連想配列で指定 省略時:”
<?php if ( has_post_thumbnail() ) : ?>
<div class="post-thumbnail">
<a href="<?php the_permalink(); ?>">
<?php the_post_thumbnail(array(200,200)); ?>
</a>
</div>
<?php else: ?>
<div class="post-thumbnail">
<a href="<?php the_permalink(); ?>">
<img src="アイキャッチ画像設定なしの時の画像パス" alt="アイキャッチ画像">
</a>
</div>
<?php endif; ?>
同じカテゴリーのコンテンツ