the_post_thumbnail

Sponsored Link

記事の編集画面で設定する投稿サムネイルを表示します。サムネイル画像は”attachment-thumbnail”クラスを与えられます。

投稿サムネイルを有効にするには、現在のテーマのfunctions.phpファイルにadd_theme_support( ‘post-thumbnails’ );を含まなければなりません。また、投稿サムネイルを参照してください。

Sponsored Link

Display Post Thumbnail as set in post’s edit screen. Thumbnail images are given class “attachment-thumbnail”.

To enable post thumbnails, the current theme must include add_theme_support( ‘post-thumbnails’ ); in its functions.php file. See also Post Thumbnails.

the_post_thumbnailのテンプレートタグ使用方法

<?php the_post_thumbnail( $size, $attr ); ?> 

the_post_thumbnailのパラメーター

$size

(string/array) (Optional)画像サイズです。

(string/array) (Optional) Image size.

デフォルト:’post-thumbnail’です。テーマはset_post_thumbnail_size( $width, $height, $crop_flag );を使用して設定します。キーワード(thumbnail, medium, large or full)か例えば配列(32,32)の幅と高さをピクセル単位で表す2項目の配列の文字列のいづれかです。

Default: ‘post-thumbnail’, which theme sets using set_post_thumbnail_size( $width, $height, $crop_flag );. Either a string keyword(thumbnail, medium, large or full) or a 2-item array representing width and height in pixels, e.g. array(32,32).

$attr

(array) (Optional)

Default: None

デフォルトの使い方

<?php the_post_thumbnail(); ?>
<?php the_content(); ?>

その他のオプション

the_post_thumbnail();  // without parameter -> Thumbnail

the_post_thumbnail('thumbnail');   // Thumbnail
the_post_thumbnail('medium');  // Medium resolution
the_post_thumbnail('large');   // Large resolution

the_post_thumbnail( array(100,100) );  // Othe resolutions

変更ログ

Since: 2.9.0

ソースファイル

the_post_thumbnail()は、wp-includes/post-thumbnail-template.php内に位置しています。

the_post_thumbnail() is located in wp-includes/post-thumbnail-template.php.

外部リソース

  • Everything you need to know about WordPress 2.9’s post image feature, by JustintAdlock.com
  • The Ultimative Guide For the_post_thumbnail In WordPress 2.9, by wpEngineer.com

関連テンプレートタグ

has_post_thumbnail, the_post_thumbnail, get_post_thumbnail_id, get_the_post_thumbnail

Sponsored Link