is_attachment()
最后更新于:2021-11-27 08:12:39
is_attachment( int|string|int[]|string[]$attachment=”)Determines whether the query is for an existing attachment page.
参数
- $attachment
-
(int|string|int[]|string[]) (Optional) Attachment ID, title, slug, or array of such to check against.
Default value: ”
响应
(bool) Whether the query is for an existing attachment page.
源文件
文件: gc-includes/query.php
function is_attachment( $attachment = '' ) {
global $gc_query;
if ( ! isset( $gc_query ) ) {
_doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always return false.' ), '3.1.0' );
return false;
}
return $gc_query->is_attachment( $attachment );
}