is_attachment

Sponsored Link

この条件タグは、添付ファイルが表示されている場合にチェックします。

Sponsored Link

添付ファイルは、投稿エディターのアップロード機能を介してアップロードされた画像やその他のファイルのことです。添付ファイルは、独自の”ページ”またはテンプレートに表示することができます。詳細については、画像と添付ファイルの使用方法を参照してください。

これは、TRUEまたはFALSEのいずれかを返すという意味のブール関数です。

This Conditional Tag checks if an attachment is being displayed. An attachment is an image or other file uploaded through the post editor’s upload utility. Attachments can be displayed on their own ‘page’ or template. For more information, see Using Image and File Attachments.

This is a boolean function, meaning it returns either TRUE or FALSE.

is_attachmentのテンプレートタグ使用方法

<?php is_attachment(); ?>

注釈

(boolean) 成功時にはtrue、失敗した場合にFALSE。

(boolean)
True on success, false on failure.

<?php
if ( is_attachment() ) {
// show adv. #1
} else {
// show adv. #2
}
?>

戻り値

  • 参照: is_singular()
  • より具体的な検査のために添付ファイルを参照してください:関数リファレンス/ WP添付ファイルはイメージです
  • See Also: is_singular()
  • For more specific checking of the attachment see: Function Reference/wp attachment is image

変更ログ

Since: 2.0.0

ソースファイル

is_attachment()は、wp-includes/functions.php内に位置しています。

is_attachment() is located in wp-includes/functions.php.

関連テンプレートタグ

Conditional Tags: comments_open(), is_404(), is_admin(), 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_multi_author, is_month(), is_new_day(), is_page(), is_page_template(), is_paged(), is plugin active(), is_plugin_page(), is_post_type_archive(), is_preview(), 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(), 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()

Sponsored Link