WordPress.org

Support

Support » How-To and Troubleshooting » Change Attached image size for Archive,Post,Home Loops

Change Attached image size for Archive,Post,Home Loops

  • I’ve found this snippet that lets me echo out the thumbnail size for the first photo but I’m still displaying the original photo. Any idea how to remove the first image? The surely then its just a case of using conditionals to control the function calls $args?

    function get_post_image($size = 'thumbnail') {
    	global $post;
    
    	$photos = get_children( array('post_parent' => $post->ID, 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID') );
    
    	if ($photos) {
    		$photo = array_shift($photos);
    		return wp_get_attachment_image($photo->ID, $size);
    	}
    	return false;
    }
    $photo = get_post_image();
  • The topic ‘Change Attached image size for Archive,Post,Home Loops’ is closed to new replies.