I have the following code in my functions.php:
function get_images($size = 'thumbnail') {
global $post;
return get_children( array('post_parent' => get_the_ID(), 'post_status' => 'inherit', 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' => 'ASC', 'orderby' => 'menu_order ID') );
}
And in my single.php
<?php $photos = get_images('full'); ?>
<?php $x = 0; ?>
<?php foreach($photos as $photo): ?>
<?php if($x < 1): ?>
<img src="<?=wp_get_attachment_url($photo->ID)?>" alt="fullImg" />
<?php endif; ?>
<?php $x++;
?>
<?php endforeach; ?>
I want to show just ONE image there, but it shows me also the post-thumb image, which I don’t want, is there an option to exclude that?
That’s some crazy coding there! It’s pointless accepting a size in your function, because it merely returns an array of post objects.
Once you’ve got your posts, then use the appropriate attachment function(s) to get the information on the attachment size you’re after.
I would propose a function like this instead;
And putting it in practice;
UPDATE: Typo in function – fixed.