Excluding a specific image from get_children according to its order number ? (1 post)

  1. supergab
    Posted 5 years ago #


    I use the following function in functions.php to output all images of a post's gallery:

    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; ?>">&nbsp;</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.

Topic Closed

This topic has been closed to new replies.

About this Topic