Skip to content

Instantly share code, notes, and snippets.

@caratage
Created November 27, 2012 04:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save caratage/4152357 to your computer and use it in GitHub Desktop.
Save caratage/4152357 to your computer and use it in GitHub Desktop.
check if post has image attachment
$attachments = get_children (
array (
'post_parent' => get_the_ID(),
'post_type' => 'attachment',
'post_mime_type' => 'image'
)
);
if ( $attachments ) {
// do conditional stuff here
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment