Excluding a specific image from get_children according to its order number ?
-
Hi,
I use the following function in functions.php to output all images of a post’s gallery:
<?php function my_attachment_image($postid=0, $size='large', $attributes='') { if ($postid<1) $postid = get_the_ID(); if ($images = get_children(array( 'post_parent' => $postid, 'post_type' => 'attachment', 'numberposts' => -1, 'orderby' => 'menu_order', 'post_mime_type' => 'image',))) foreach($images as $image) { $attachment=wp_get_attachment_image_src($image->ID, $size); ?><a href="<?php echo $attachment[0]; ?>" <?php echo $attributes; ?> rel="fancybox-<?php echo $postid; ?>"> </a><?php } }?>
The only thing missing from this function for me right now it the ability to exclude a specific image. That specific image would be the one with number 1 manually specified in the order field of the gallery.
I tried adding this with no luck:
‘exclude’ => ‘1’,
Many thanks for your time and help.
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Excluding a specific image from get_children according to its order number ?’ is closed to new replies.