PHedkvist
Member
Posted 4 months ago #
I want to have a list with images from my posts, but how do i link my thumbnail to it? I have been looking around for someway to put in an image from one of my posts to display in a list but i cant find a way. Any tips?
Ex:
<ul class="gallery">
<li><img src="/images/image_tn.jpg" alt="image" /></li>
</ul>
Instead of /images/image_tn.jpg i would like a link to my post thumbnail url.
You can use probably use WP_Query or query_posts to display the attachment from each post. Something like (this has not been tested):
<?php
$args = array( 'post_type' => 'attachment', 'posts_per_page' => 5 );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
?>
This article may also help:
http://codex.wordpress.org/Template_Tags/get_posts#Show_all_attachments
PHedkvist
Member
Posted 4 months ago #
Can 'attachment' be used instead of the thumbnail function?