When I add this code into my template, i see all of the thumbnails and my links are generating correctly. The only problem is that I’m also seeing the word “Array” in the page next to each thumbnail. Where is this array word coming from and how do i get rid of it? Seems very bizarre.
<?php
$args = array(
'post_type' => 'attachment',
'numberposts' => -1,
'post_status' => null,
'post_parent' => $post->ID
);
$attachments = get_posts($args);
if ($attachments) {
foreach ($attachments as $attachment) {
//wp_get_attachment_thumb_url($post->ID);
/* $img_attr_full = wp_get_attachment_image_src(get_post_thumbnail_id(), 'full');
$img_attr_thumb = wp_get_attachment_image_src(get_post_thumbnail_id(), 'thumbnail'); */
echo '<li type="1">';
echo '<a id="' . $post->ID . '" href="' . $img_attr_full[0] . '" class="gallery ' . $media_type . ' ' . $media . '" data-media-type="' . $media . '" target="_blank" rel="gallery">';
echo wp_get_attachment_image($attachment->ID, 'thumbnail');
echo '</a></li>';
}
}
See this: the implementation of
wp_get_attachment_image_srcwhich you are using to fetch the URL for theaelement returns an array.EDIT:
echo $attachments;will print outArray. If you remove that you should get better results. In addition, provide a coherent code sample that reflects what is actually in use and producing the error, or you’ll cause confusion.