Retrieve permalink to attachment page / ID
I am trying to retrieve the link or better permalink, inside single-post.php, to the page that displays the featured image (and uses an image.php template)
I manage with this
<a href="<?php bloginfo('url')?>/?attachment_id=<?php echo get_post_thumbnail_id(); ?>"><?php the_title() ?> </a>
To get this:
Yet I d like to get the permalink, but whatever I try I end up getting the URL of the post the attachment is attached to (or parent page), that is the post I am on, and not the URL of the image template.
- The topic ‘Retrieve permalink to attachment page / ID’ is closed to new replies.