hi there,
I'm using the following code inside my loop to display portfolio images:
<a href="<?php wp_get_attachment_thumb_url( get_post_thumbnail_id( $post->ID ) ); ?>"><?php the_post_thumbnail( 'single-post-thumbnail' ); ?></a>
The image appears fine, but I can't retrieve the link url. The code <?php wp_get_attachment_thumb_url( get_post_thumbnail_id( $post->ID ) ); ?> is obviously wrong.
Anyone know what it should be?
CatherineWinters
Member
Posted 1 year ago #
Sure, try this:
<a href="<?php print wp_get_attachment_thumb_url( get_post_thumbnail_id( $post->ID ) ); ?>"><?php the_post_thumbnail( 'single-post-thumbnail' ); ?></a>
wp_get_attachment_thumb_url() just returns the resulting URL; it doesn't actually do anything with it. To get it to print out, you need to use print.
I managed to get the url, but it won't keep my external link. Instead it uses the link to the attachment. I gave up and in the end, just used a custom field.