- 赤色のリンクは、まだ日本語Codexに存在しないページ・画像です。英語版と併せてご覧ください。(詳細)
テンプレートタグ/get the post thumbnail
提供: WordPress Codex 日本語版
このページ「テンプレートタグ/get the post thumbnail」は未翻訳です。和訳や日本語情報を加筆してくださる協力者を求めています。
タグ一覧: テンプレートタグ | インクルードタグ | 条件分岐タグ | その他の関数 | Code Reference
使い方: テンプレートタグ入門 | パラメータの渡し方 | 初心者の方へ | その他のテーマ関連資料
目次
Description
Gets Post Thumbnail as set in post's or page's edit screen. Thumbnail images are given class "attachment-thumbnail"
Usage
<?php echo get_the_post_thumbnail( $id, $size, $attr ); ?>
Parameters
- $id
- (int) (Required) Post ID.
- 初期値: なし
- $size
- (int) (Optional) Image size.
- 初期値: 'thumbnail'
- $attr
- (int) (Optional)
- 初期値: なし
Examples
Sample Usage
<?php $pages = get_pages(array('child_of' => 1)); ?> <ul> <?php foreach ($pages as $page): ?> <li> <?php echo get_the_post_thumbnail($page->ID, 'thumbnail'); ?> <h1><?=$page->post_title?></h1> <?=$page->post_content?> </li> <?php endforeach; ?> </ul>
More Options
get_the_post_thumbnail($id); // without parameter -> Thumbnail get_the_post_thumbnail($id, 'thumbnail'); // Thumbnail get_the_post_thumbnail($id, 'medium'); // Medium resolution get_the_post_thumbnail($id, 'large'); // Large resolution get_the_post_thumbnail($id, array(100,100) ); // Other resolutions
Notes
To enable post thumbnails, the current theme must include add_theme_support( 'post-thumbnails' );
in its functions.php file.
変更履歴
- 2.9 : 新規テンプレートタグ
Source File
get_the_post_thumbnail() is located in wp-includes/post-thumbnail-template.php
.
External Resources
- 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
最新英語版: WordPress Codex » Template Tags/get_the_post_thumbnail (最新版との差分)
Related
投稿サムネイル: has_post_thumbnail, the_post_thumbnail, get_post_thumbnail_id, get_the_post_thumbnail, add_image_size(), set_post_thumbnail_size()
関数リファレンス、テンプレートタグ目次もご覧ください。