- 赤色のリンクは、まだ日本語Codexに存在しないページ・画像です。英語版と併せてご覧ください。(詳細)
「テンプレートタグ/the post thumbnail」の版間の差分
提供: WordPress Codex 日本語版
< テンプレートタグ
細 (→Notes) |
(残りの翻訳・修正、リンク調整等/size パラメータのロジックが分かる方、説明を直してください~) |
||
1行目: | 1行目: | ||
{{NeedTrans}} | {{NeedTrans}} | ||
+ | {{テンプレートタグガイド|PHP}} | ||
== 説明 == | == 説明 == | ||
投稿編集画面で設定すると、投稿サムネイルを表示します。サムネイル画像には "attachment-thumbnail" クラスが付与されます。 | 投稿編集画面で設定すると、投稿サムネイルを表示します。サムネイル画像には "attachment-thumbnail" クラスが付与されます。 | ||
− | 投稿サムネイルを有効にするには、使用しているテーマの[[ | + | 投稿サムネイルを有効にするには、使用しているテーマの [[テーマの作成#Theme Functions File|<tt>functions.php</tt> ファイル]]に <code>add_theme_support( 'post-thumbnails' );</code> を追加する必要があります。[[Post Thumbnails|投稿サムネイル]]も参照してください。 |
== 使い方 == | == 使い方 == | ||
10行目: | 11行目: | ||
<?php the_post_thumbnail( $size, $attr ); ?> | <?php the_post_thumbnail( $size, $attr ); ?> | ||
− | + | == パラメータ ==<!-- Parameters --> | |
− | + | {{Parameter|size|整数|画像サイズ。|任意|<!-- 'post-thumbnail', which theme sets using <code>set_post_thumbnail_size( $width, $height, $crop_flag );</code> --><code>set_post_thumbnail_size( $width, $height, $crop_flag );</code> を用いてテーマが設定する 'post-thumbnail'。(訳注: やや意味不明。ロジックが分かる方、直してください~)}} | |
− | + | {{Parameter|attr|整数||任意}} | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
== 用例 == | == 用例 == | ||
− | |||
=== デフォルトの使用例 === | === デフォルトの使用例 === | ||
27行目: | 23行目: | ||
<?php the_content(); ?> | <?php the_content(); ?> | ||
− | + | === オプション ===<!-- More Options --> | |
− | === オプション === | + | |
− | < | + | |
the_post_thumbnail(); // パラメータなし -> サムネイル | the_post_thumbnail(); // パラメータなし -> サムネイル | ||
39行目: | 33行目: | ||
the_post_thumbnail( array(100,100) ); // 他のサイズ | the_post_thumbnail( array(100,100) ); // 他のサイズ | ||
− | + | == 変更履歴 ==<!-- Changelog --> | |
− | + | ||
− | + | ||
− | + | ||
− | == Changelog | + | |
− | + | * [[Version 2.9|2.9.0]] : 新規テンプレートタグ | |
− | == | + | == ソースファイル ==<!-- Source File --> |
− | + | * {{BrowseSource|wp-includes/post-thumbnail-template.php}} | |
− | == | + | == 外部資料 ==<!-- External Resources --> |
* [http://justintadlock.com/archives/2009/11/16/everything-you-need-to-know-about-wordpress-2-9s-post-image-feature Everything you need to know about WordPress 2.9’s post image feature], by JustintAdlock.com | * [http://justintadlock.com/archives/2009/11/16/everything-you-need-to-know-about-wordpress-2-9s-post-image-feature Everything you need to know about WordPress 2.9’s post image feature], by JustintAdlock.com |
2010年3月3日 (水) 21:01時点における版
このページ「テンプレートタグ/the post thumbnail」は未翻訳です。和訳や日本語情報を加筆してくださる協力者を求めています。
タグ一覧: テンプレートタグ | インクルードタグ | 条件分岐タグ | その他の関数 | Code Reference
使い方: テンプレートタグ入門 | パラメータの渡し方 | 初心者の方へ | その他のテーマ関連資料
説明
投稿編集画面で設定すると、投稿サムネイルを表示します。サムネイル画像には "attachment-thumbnail" クラスが付与されます。
投稿サムネイルを有効にするには、使用しているテーマの functions.php ファイルに add_theme_support( 'post-thumbnails' );
を追加する必要があります。投稿サムネイルも参照してください。
使い方
<?php the_post_thumbnail( $size, $attr ); ?>
パラメータ
- size
- (整数) (任意) 画像サイズ。
- 初期値:
set_post_thumbnail_size( $width, $height, $crop_flag );
を用いてテーマが設定する 'post-thumbnail'。(訳注: やや意味不明。ロジックが分かる方、直してください~)
- 初期値:
- attr
- (整数) (任意)
- 初期値: なし
用例
デフォルトの使用例
<?php the_post_thumbnail(); ?> <?php the_content(); ?>
オプション
the_post_thumbnail(); // パラメータなし -> サムネイル the_post_thumbnail('thumbnail'); // サムネイル the_post_thumbnail('medium'); // 中サイズ the_post_thumbnail('large'); // 大サイズ the_post_thumbnail( array(100,100) ); // 他のサイズ
変更履歴
- 2.9.0 : 新規テンプレートタグ
ソースファイル
外部資料
- 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/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()