- 赤色のリンクは、まだ日本語Codexに存在しないページ・画像です。英語版と併せてご覧ください。(詳細)
「関数リファレンス/has excerpt」の版間の差分
細 (→関連資料: Category:関数) |
細 (最新版のマージ) |
||
(同じ利用者による、間の1版が非表示) | |||
12行目: | 12行目: | ||
== パラメータ == | == パラメータ == | ||
</div> | </div> | ||
− | {{Parameter|$id|整数|投稿 ID| | + | {{Parameter|$id|整数|投稿 ID|オプション|今の投稿 ID}} |
<div id="Return_value"> | <div id="Return_value"> | ||
18行目: | 18行目: | ||
</div> | </div> | ||
; <tt>(boolean)</tt> : 抜粋がある場合は <tt>true</tt> を、さもなくば <tt>false</tt> を返します。 | ; <tt>(boolean)</tt> : 抜粋がある場合は <tt>true</tt> を、さもなくば <tt>false</tt> を返します。 | ||
+ | |||
+ | |||
+ | == 用例 == | ||
+ | |||
+ | <pre><?php | ||
+ | // Get $post if you're inside a function | ||
+ | global $post; | ||
+ | |||
+ | if ( has_excerpt( $post->ID ) ) { | ||
+ | // This post has excerpt | ||
+ | } else { | ||
+ | // This post has no excerpt | ||
+ | } | ||
+ | ?></pre> | ||
+ | |||
+ | |||
+ | <b>その他の使い方</b> | ||
+ | |||
+ | 自動表示された抜粋を非表示にして、あなたの投稿の抜粋を表示する必要がある場合。 | ||
+ | |||
+ | <pre> | ||
+ | <?php if ( ! has_excerpt() ) { | ||
+ | echo ''; | ||
+ | } else { | ||
+ | the_excerpt(); | ||
+ | } | ||
+ | </pre> | ||
+ | |||
+ | テキストやコードの自動抜粋をリプレイスします。 | ||
+ | |||
+ | <pre> | ||
+ | <?php if ( ! has_excerpt() ) {?> | ||
+ | <!-- you text or code --> | ||
+ | <?php } ?> | ||
+ | </pre> | ||
<div id="Change_log"> | <div id="Change_log"> | ||
32行目: | 67行目: | ||
== 関連資料 == | == 関連資料 == | ||
</div> | </div> | ||
− | |||
− | {{原文|Function Reference/has excerpt| | + | |
+ | {{Conditional Tags}} | ||
+ | |||
+ | {{Tag Footer}} | ||
+ | |||
+ | {{原文|Function Reference/has excerpt|148991}}<!--21:00, 11 January 2015 Jdgrimes --> | ||
+ | |||
+ | [[Category:条件分岐タグ]] | ||
+ | [[Category:関数]] |
2015年6月12日 (金) 09:44時点における最新版
投稿に抜粋があるか否かを判断する関数です。
使い方
<?php has_excerpt( $id ); ?>
パラメータ
- $id
- (整数) (オプション) 投稿 ID
- 初期値: 今の投稿 ID
戻り値
- (boolean)
- 抜粋がある場合は true を、さもなくば false を返します。
用例
<?php // Get $post if you're inside a function global $post; if ( has_excerpt( $post->ID ) ) { // This post has excerpt } else { // This post has no excerpt } ?>
その他の使い方
自動表示された抜粋を非表示にして、あなたの投稿の抜粋を表示する必要がある場合。
<?php if ( ! has_excerpt() ) { echo ''; } else { the_excerpt(); }
テキストやコードの自動抜粋をリプレイスします。
<?php if ( ! has_excerpt() ) {?> <!-- you text or code --> <?php } ?>
変更履歴
2.3.0にて導入されました。
ソースファイル
comments_template() は wp-includes/post-template.php
にあります。
関連資料
条件分岐タグ:
is_404(),
is_admin(),
is_admin_bar_showing(),
is_archive(),
is_attachment(),
is_author(),
is_category(),
is_comments_popup(),
is_date(),
is_day(),
is_feed(),
is_front_page(),
is_home(),
is_local_attachment(),
is_main_query,
/is_multi_author,
is_month(),
is_new_day(),
is_page(),
is_page_template(),
is_paged(),
is_plugin_active(),
is_plugin_active_for_network() /en,
is_plugin_inactive() /en,
is_plugin_page() /en,
is_post_type_archive(),
is_preview() /en,
is_search(),
is_single(),
is_singular(),
is_sticky(),
is_tag(),
is_tax(),
is_taxonomy_hierarchical(),
is_time(),
is_trackback(),
is_year(),
in_category(),
in_the_loop(),
is_active_sidebar(),
is_active_widget(),
is_blog_installed() /en,
is_rtl(),
is_dynamic_sidebar(),
is_user_logged_in(),
has_excerpt(),
has_post_thumbnail(),
has_tag(),
pings_open(),
email_exists(),
post_type_exists(),
taxonomy_exists(),
term_exists(),
username_exists() /en,
wp_attachment_is_image(),
wp_script_is()
最新英語版: WordPress Codex » Function Reference/has excerpt (最新版との差分)