<?php the_content();?>
을 사용하면 모든 게시물 내용을 볼 수 있지만 어떻게 게시물에 첨부 된 이미지 만 표시 할 수 있습니까?Wordpress에서 이미지 첨부
감사
<?php the_content();?>
을 사용하면 모든 게시물 내용을 볼 수 있지만 어떻게 게시물에 첨부 된 이미지 만 표시 할 수 있습니까?Wordpress에서 이미지 첨부
감사
이러한 수치는 유용하게 사용할 수 :
당신은 이미지의 모든 게시물을 나열하고 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>