- 赤色のリンクは、まだ日本語Codexに存在しないページ・画像です。英語版と併せてご覧ください。(詳細)
「関数リファレンス/has post thumbnail」の版間の差分
提供: WordPress Codex 日本語版
< 関数リファレンス
(en:Template Tags/has_post_thumbnail 18:08, 4 February 2010 Kyuumeitai 版を翻訳用にコピー) |
細 (整形・リンク調整、試験的にテーマテンプレートガイドを挿入、未翻訳) |
||
1行目: | 1行目: | ||
− | == | + | {{テンプレートタグガイド|PHP}} |
+ | == 説明 == | ||
Returns a boolean if post has an image attached (true) or not (false). | Returns a boolean if post has an image attached (true) or not (false). | ||
− | '''Note:''' To enable post thumbnails, the current theme must include <code>add_theme_support( 'post-thumbnails' );</code> in its <tt>[[ | + | '''Note:''' To enable post thumbnails, the current theme must include <code>add_theme_support( 'post-thumbnails' );</code> in its <tt>[[テーマの作成#Theme Functions File|functions.php]]</tt> file. |
− | == | + | == 使い方 == |
− | + | <?php has_post_thumbnail( $post_id ); ?> | |
− | == Parameters == | + | == Parameters ==<!-- Parameters --> |
− | {{Parameter|$post_id| | + | {{Parameter|$post_id|整数|Post ID.|任意|'ID', the post ID.}} |
− | == | + | == 用例 ==<!-- Examples --> |
This script asks if there is, actually, a thumbnail in the post. If it's not, it will put a default image. | This script asks if there is, actually, a thumbnail in the post. If it's not, it will put a default image. | ||
28行目: | 29行目: | ||
</pre> | </pre> | ||
− | == | + | == 変更履歴 ==<!-- Changelog --> |
− | + | * [[Version 2.9|2.9.0]] : 新規テンプレートタグ | |
− | == | + | == ソースファイル ==<!-- Source File --> |
<tt>has_post_thumbnail()</tt> is located in {{Trac|wp-includes/post-thumbnail-template.php}}. | <tt>has_post_thumbnail()</tt> is located in {{Trac|wp-includes/post-thumbnail-template.php}}. | ||
38行目: | 39行目: | ||
{{原文|Template Tags/has_post_thumbnail|82659}}<!-- 18:08, 4 February 2010 Kyuumeitai 版 --> | {{原文|Template Tags/has_post_thumbnail|82659}}<!-- 18:08, 4 February 2010 Kyuumeitai 版 --> | ||
− | == | + | == 関連 ==<!-- Related --> |
{{Post Thumbnail Tags}} | {{Post Thumbnail Tags}} | ||
{{Tag Footer}} | {{Tag Footer}} | ||
− | [[Category: | + | {{DEFAULTSORT:Has_post_thumbnail}} |
+ | [[Category:wp2.9]] | ||
[[en:Template Tags/has_post_thumbnail]] | [[en:Template Tags/has_post_thumbnail]] |
2010年3月3日 (水) 21:10時点における版
タグ一覧: テンプレートタグ | インクルードタグ | 条件分岐タグ | その他の関数 | Code Reference
使い方: テンプレートタグ入門 | パラメータの渡し方 | 初心者の方へ | その他のテーマ関連資料
説明
Returns a boolean if post has an image attached (true) or not (false).
Note: To enable post thumbnails, the current theme must include add_theme_support( 'post-thumbnails' );
in its functions.php file.
使い方
<?php has_post_thumbnail( $post_id ); ?>
Parameters
- $post_id
- (整数) (任意) Post ID.
- 初期値: 'ID', the post ID.
用例
This script asks if there is, actually, a thumbnail in the post. If it's not, it will put a default image.
<?php //This must be in one loop if(has_post_thumbnail()) { the_post_thumbnail(); } else { echo '<img src="'.get_bloginfo("template_url").'/images/img-default.png" />'; } ?>
変更履歴
- 2.9.0 : 新規テンプレートタグ
ソースファイル
has_post_thumbnail() is located in wp-includes/post-thumbnail-template.php
.
最新英語版: WordPress Codex » Template Tags/has_post_thumbnail (最新版との差分)
関連
投稿サムネイル: has_post_thumbnail, the_post_thumbnail, get_post_thumbnail_id, get_the_post_thumbnail, add_image_size(), set_post_thumbnail_size()
関数リファレンス、テンプレートタグ目次もご覧ください。