Created
October 6, 2011 16:14
-
-
Save contempoinc/1267823 to your computer and use it in GitHub Desktop.
Check if post has more than one image attached in WordPress
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Check if post has more than one image attached | |
* | |
* @author Chris Robinson | |
* @link http://contempographicdesign.com | |
*/ | |
$attachments = get_children( | |
array( | |
'post_type' => 'attachment', | |
'post_mime_type' => 'image', | |
'post_parent' => $post->ID | |
)); | |
if(count($attachments) > 1) { ?> | |
<!-- Do something like show a slider --> | |
<?php } else { ?> | |
<!-- Display a single image --> | |
<?php } ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment