Reputation: 5393
Hi I am trying to instegrate a slider into my wordpress theme.This is what I have so far:
<?php
$slider_query = new WP_Query(array(
'posts_per_page'=>'5'
));
if($slider_query->have_posts()):
while($slider_query->have_posts()):
$slider_query->the_post();
if(function_exists('has_post_thumbnail') && has_post_thumbnail()){
the_post_thumbnail();
}
endwhile;
endif;
?>
While this does work and retrieves the image I need to be able to retribe the url because I have to set different title attributes that are stored for the caption.
Anyone know of a way to retrieve the thumbnail url?
EDIT: I have also tryed to get the URL using
$url = wp_get_attachment_image_src(the_post_thumbnail());
But for som reason the query returns 10 links img's and I set it to 5 only.Wierd thing is that the even images have no source.
Upvotes: 0
Views: 1109
Reputation: 536
Try using wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'wanted-size' );
. (replace wanted-size
with the correct size).
More on get_post_thumbnail_id
here.
Upvotes: 1