サムネイルがあったら表示。なかった代替画像表示。サムネイルのサイズ指定
<? php
if (has_post_thumbnail()) {
the_post_thumbnail( 'middle-feature',''); // 200pxのアイキャッチ画像設定
}else {
echo '<img src="http://placehold.it/200x200/ccc/ccc&text=coccot" />';
}
// アイキャッチの有効化
add_theme_support( 'post-thumbnails' );
//サムネイルのサイズの指定
// 'middle-feature'という名前で幅、高さ200pxのサムネイルを作成
add_image_size( 'middle-feature', 200, 200, true );
// 'small-feature'という名前で幅、高さ123pxのサムネイルを作成
add_image_size( 'small-feature', 123, 123, true );