• 赤色のリンクは、まだ日本語Codexに存在しないページ・画像です。英語版と併せてご覧ください。(詳細

このWikiはいつでも誰でも編集できます

「関数リファレンス/has post thumbnail」の版間の差分

提供: WordPress Codex 日本語版
移動先: 案内検索
(en:Template Tags/has_post_thumbnail 18:08, 4 February 2010 Kyuumeitai 版を翻訳用にコピー)
 
(整形・リンク調整、試験的にテーマテンプレートガイドを挿入、未翻訳)
1行目: 1行目:
== Description ==
+
{{テンプレートタグガイド|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>[[Theme Development#Theme Functions File|functions.php]]</tt> file.
+
'''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.
  
== Usage ==
+
== 使い方 ==
  
%%% <?php has_post_thumbnail( $post_id ); ?> %%%
+
<?php has_post_thumbnail( $post_id ); ?>
  
== Parameters ==
+
== Parameters ==<!-- Parameters -->
  
{{Parameter|$post_id|int|Post ID.|Optional|'ID', the post ID.}}
+
{{Parameter|$post_id|整数|Post ID.|任意|'ID', the post ID.}}
  
== Examples ==
+
== 用例 ==<!-- 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>
  
== Change Log  ==
+
== 変更履歴 ==<!-- Changelog -->
  
Since: 2.9.0
+
* [[Version 2.9|2.9.0]] : 新規テンプレートタグ
  
== Source File ==
+
== ソースファイル ==<!-- 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 ==
+
== 関連 ==<!-- Related -->
  
 
{{Post Thumbnail Tags}}
 
{{Post Thumbnail Tags}}
 
{{Tag Footer}}
 
{{Tag Footer}}
  
[[Category:Template Tags]]
+
{{DEFAULTSORT:Has_post_thumbnail}}
 +
[[Category:wp2.9]]
  
 
[[en:Template Tags/has_post_thumbnail]]
 
[[en:Template Tags/has_post_thumbnail]]

2010年3月3日 (水) 21:10時点における版

説明

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()


関数リファレンステンプレートタグ目次もご覧ください。