Support » Developing with WordPress » How to get Attachment Page Link

  • Hello,
    I am trying to make a theme and I am trying to get an attachment image and its attachment page link. I do lots of searches and can’t find out the solution. I can only grab the image but not the attachment page link. Can anyone help me with that? Here is the code I found.

    <?php echo get_the_post_thumbnail( $page->ID, 'thumbnail' ); ?>

    With this, I can show the image but not the attachment page link. Because every image has its own attachment page link.

    I am looking for this kind of link

    <a href="https://mysite.com/my-post-title-comes-here/post-id/attachment-page" target="_blank"><?php echo get_the_post_thumbnail( $page->ID, 'thumbnail' ); ?></a>

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to get Attachment Page Link’ is closed to new replies.