2014-04-04 1 views
0

누군가 도움이 될 수 있습니다. 이 코드를 표준 템플릿에 넣었지만 이미지가있는 게시물이 많은데도 이미지가 표시되지 않습니다.WordPress : 전면 이미지에 게시물 이미지 표시

<?php if (have_posts()) : while (have_posts()) : the_post();  

$images =& get_children(array (
    'post_parent' => $post->ID, 
    'post_type' => 'attachment', 
    'post_mime_type' => 'image' 
)); 

if (empty($images)) { 
    // no attachments here 
} else { 
    foreach ($images as $attachment_id => $attachment) { 
     echo wp_get_attachment_image($attachment_id, 'thumbnail'); 
    } 
} 

endwhile; endif; ?> 

감사합니다.

+0

이미지 만 표시하면 되나요? 이미지가 특집 이미지로 설정되어 있습니까? –

+0

아니요, 추천 이미지로 설정되지 않았습니다. 이미지 만 표시하면됩니다. 나는 그들을 배치하기 위해 Masonry와 CSS를 사용할 것이다. – natnai

답변

1

변화

echo wp_get_attachment_image($attachment_id, 'thumbnail'); 

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

$images =& get_children(array (
    'post_parent' => $post->ID, 
    'post_type' => 'attachment', 
    'post_mime_type' => 'image' 
)); 

$images =get_posts(array (
    'post_parent' => $post->ID, 
    'post_type' => 'attachment', 
    'post_mime_type' => 'image' 
)); 

행 이것은 당신 것입니다

<?php if (have_posts()) : while (have_posts()) : the_post();  

$args = array(
    'post_type' => 'attachment', 
    'numberposts' => -1, 
); 

    $attachments = get_posts($args); 
    if ($attachments) { 
     foreach ($attachments as $attachment) { 
      echo wp_get_attachment_image($attachment->ID, 'full'); 
      } 
    } 

endwhile; endif; ?> 

이 코드는 미디어 라이브러리의 모든 '큰'이미지를 가져오고 그들에게

희망을 표시합니다 : 당신은 당신이 뭔가를 할 수 get_posts()

+0

여전히 작동하지 않습니다./ – natnai

+0

http://www.vcluxe.nu/ – natnai

+0

당신은'print_r ($ images)' – Dinesh

0

를 사용한다 찾고 있었어

관련 문제