• 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?

Viewing 2 replies - 1 through 2 (of 2 total)
  • 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.

    Thread Starter Christine Rondeau

    (@crondeau)

    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.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Retrieve the link url for the thumbnail’ is closed to new replies.