The following snippet of code will check to see if your post or custom post type has any attachments and then allows you to use an if else statement. You can change the number of attachments to check for, so if you wanted to check if there is more than one attachment while not counting the featured image you could use this. To change the number of attachments to check for just change the number from 1 to whatever you want it to be (on line 9).


 'attachment',
        'post_mime_type' => 'image',
        'post_parent' => $post->ID
    ));
if(count($attachments) > 1) { ?>
    

    


Found this awesome snippet on WPSnipp

Leave a Reply

Get in Touch

Please fill out the form below and we will get back to you ASAP

  • This field is for validation purposes and should be left unchanged.