Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question
    
where and how is $oID defined? –  iEmanuele Aug 28 '13 at 11:47
    
Just try removing 'numberposts' => null parameter from get_posts() function array $args –  Vinod Dalvi Aug 28 '13 at 12:35
add comment

1 Answer

Replace the line

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

with

echo $attachments['post_content'];
share|improve this answer
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 Aug 28 '13 at 11:25
    
I have edited my answer, please try the above code. –  user930026 Aug 28 '13 at 11:39
    
$attachments is an array. –  s_ha_dum Aug 28 '13 at 11:58
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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