0

On single.php theme template file, I'm displaying the post's list of attachments.

global $post;
$args = array(
    'post_type' => 'attachment',
    'numberposts' => null,
    'post_status' => null,
    'post_parent' => $o_ID
);
$attachments = get_posts($args);
if ($attachments) {
    echo '<ul class="slideshow-controller">';
    foreach ($attachments as $attachment) {
        //echo apply_filters('the_title', $attachment->post_title);
        echo '<li>';
        echo wp_get_attachment_link($attachment->ID, 'thumbnail', 0, 0, 'Download');
        echo wp_get_attachment_image($attachment->ID, 'thumbnail',false);
        echo '</li>';
    }
    echo '</ul>';
}

Weird, wp_get_attachment_linkworks correctly (echoes the attachment's media link), wp_get_attachment_imagedoes not: it echoes nothing at all.

What am i doing wrong?

2
  • where and how is $oID defined?
    – iEmanuele
    Commented Aug 28, 2013 at 11:47
  • Just try removing 'numberposts' => null parameter from get_posts() function array $args Commented Aug 28, 2013 at 12:35

1 Answer 1

0

Replace the line

echo wp_get_attachment_image($attachment->ID, 'thumbnail',false);

with

echo $attachments['post_content'];
3
  • 1
    Thank you, but that does not solve the issue: false refers to the use of the media icon, which is false by default.
    – pixeline
    Commented Aug 28, 2013 at 11:25
  • I have edited my answer, please try the above code.
    – user930026
    Commented Aug 28, 2013 at 11:39
  • $attachments is an array.
    – s_ha_dum
    Commented Aug 28, 2013 at 11:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.