WordPress.org

Codex

Interested in functions, hooks, classes, or methods? Check out the new WordPress Code Reference!

Function Reference/is attachment

Description

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.

Usage

<?php is_attachment(); ?>

Parameters

Return Values

(boolean) 
True on success, false on failure.

Examples

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

Notes

Change Log

Since: 2.0.0

Source File

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

Related

See also index of Function Reference and index of Template Tags.