A web developer's blog. PHP, MySQL, CakePHP, Zend Framework, Wordpress, Code Igniter, Django, Python, CSS, Javascript, jQuery, Knockout.js, and other web development topics.

WordPress: Get post thumbnail of Featured Image

Note: I’m posting this for myself so that I can refer to it in the future.

$cat_id =get_cat_id('Uncategorized');
$query = new WP_Query('cat='.$cat_id.'&year='.$year.'&monthnum='.$month.'&day='.$day);
$image = false;
while ( $query->have_posts() )  {
    $image = wp_get_attachment_image_src(get_post_thumbnail_id($query->ID));
    echo '<a href="'.$image[0].'">';

More here for wp_get_attachment_image_src
Related: get_post_thumbnail.

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>