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

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -