2010-08-14 9 views

답변

2

당신은 이미지의 모든 게시물을 나열하고 wp_get_attachment_url를 사용하여 쿼리를 만들 수 있습니다, wp_get_attachment_image 또는 wp_get_attachment_link. 아래 코드는 모든 게시물의 이미지 첨부 파일을 모두 가져 와서 루프 (즉, 이미지 갤러리)에 표시합니다.

<ul> 
     <?php 
     $wp_query = new WP_Query(array('post_type' => 'attachment','post_mime_type' =>'image','post_status' => 'inherit', 'posts_per_page' => '20', 'orderby' => 'date','order' => 'DESC')); 
     if($wp_query->have_posts()) : while ($wp_query->have_posts()) : $wp_query->the_post();?> 
       <li> 
       <a href="<?php echo wp_get_attachment_url($post->ID); ?>" 
       class="post-images" 
       title="<?php the_title(); ?>" > 
       <img width="100" height="100" src="<?php echo wp_get_attachment_thumb_url($post->ID);?>" /></a> 
       </li> 
     <?php endwhile; ?> 
     </ul> 
관련 문제