• So, below is the WordPress default generated code for an image:

    <div class="image-section">
    <a href="https://websitename.com/wp-content/uploads/2019/06/image-1.jpg" target="_blank" rel="noopener noreferrer">
    <img src="https://websitename.com/wp-content/uploads/2019/06/image-1.jpg"/></a></div>
    <div class="image-section">
    <a href="https://websitename.com/wp-content/uploads/2019/06/image-2.jpg" target="_blank" rel="noopener noreferrer">
    <img src="https://websitename.com/wp-content/uploads/2019/06/image-2.jpg"/></a></div>

    I have no idea to get image attachment link for a tag

    I can’t change URL for each image, Is there any possibilities to get the attachment link for <a> instead of the image URL

    This is what I am expecting

    <div class="image-section">
    <a href="current_image_attachment_url" target="_blank" rel="noopener noreferrer">
    <img src="https://websitename.com/wp-content/uploads/2019/06/image-1.jpg"/></a></div>
    <div class="image-section">
    <a href="current_image_attachment_url" target="_blank" rel="noopener noreferrer">
    <img src="https://websitename.com/wp-content/uploads/2019/06/image-2.jpg"/></a></div>

    Thank you in advance, if you can help me.

    • This topic was modified 5 years, 5 months ago by jayapal13.
    • This topic was modified 5 years, 5 months ago by jayapal13.
Viewing 1 replies (of 1 total)
  • If you are in the block editor, the details are in the sidebar. You can choose the link destination (it’s near the bottom).

    If you are in the classic editor, the Add Media dialog has all the details in the sidebar. You can choose the link destination (it’s also near the bottom).

Viewing 1 replies (of 1 total)
  • The topic ‘How to get dynamically attachment image url for tag?’ is closed to new replies.