WordPress.org

Support

Support » How-To and Troubleshooting » Retrieve permalink to attachment page / ID

Retrieve permalink to attachment page / ID

  • Agnes

    @agneslesagegmailcom

    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:
    http://www.mysite.com/?attachment_id=2545

    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.

    Any idea?

Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Retrieve permalink to attachment page / ID’ is closed to new replies.