How to get dynamically link to thumbnail in Wordpress -


how instead of href="img/1.jpg, image thumbnail url wordpress function..

<a class="popup-link" href="img/1.jpg"></a> 

you can image thumbnail url wordpress function..

<?php wp_get_attachment_image_src( $attachment_id, $size, $icon ); ?>  

sample usage example :

<?php $imgarray = wp_get_attachment_image_src( get_post_thumbnail_id($post->id),'full'); $imgurl = $imgarray[0]; ?> <a class="popup-link" href="<?php echo $imgurl;?>"></a> 

reference codex

https://codex.wordpress.org/function_reference/wp_get_attachment_image_src


Comments