Hi everybody, here is a simple snippet which allows you to extract the source of the post thumbnail image on WordPress. It’s very useful if you need post thumbnail URL to use in your code.
Simply copy and paste the following code to your theme template. Please make sure that the code is pasted within the loop.
<?php // Get WordPress Thumbnail URL $image_id = get_post_thumbnail_id(); $image_url = wp_get_attachment_image_src($image_id); $image_url = $image_url[0]; ?> |