Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Hi I'm using some code to create a slideshow with lytebox functionality - the following code is used in the loop to pull each image attached to a post in sequence.

It seems to be only pulling the large image, even thought I've set the value to medium - any ideas how I can get .wp_get_attachment_url($attachment->ID, 'medium', false, false) to be pulling the medium sized images?


$argsThumb = array(
'order'          => 'DESC',
'post_type'      => 'attachment',
'post_parent'    => $post->ID,
'post_mime_type' => 'image',
'post_status'    => null
$attachments = get_posts($argsThumb);
if ($attachments) {
foreach ($attachments as $attachment) {
echo '<div class="images"><a class="lytebox" href="' .wp_get_attachment_url($attachment->ID, 'medium', false, false). '"><img src="'.wp_get_attachment_url($attachment->ID, 'medium', false, false).'" /><div class="caption">'.apply_filters('the_content', $attachment->post_content).'</div></a></div>';


share|improve this question

1 Answer 1

up vote 3 down vote accepted

wp_get_attachment_url() will only return url to original attachment file, this function only accepts attachment id as parameter.

Use wp_get_attachment_src() or wp_get_attachment_image() instead.

share|improve this answer
neither of those seem to return the url though do they? –  JorgeLuisBorges Mar 12 '12 at 16:55
wp_get_attachment_src() returns array and first parameter is image url. See linked codex page for more details. –  Mamaduka Mar 12 '12 at 17:01

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.