Archive for the ‘Wordpress’ Category

WordPress: Get post thumbnail image function

January 17, 2013 Leave a comment

So I’ve been using the bdw_get_images function (thanks to John Crenshaw and RLM Web Design & Marketing) for a couple of years to generate thumbnails on the index, and sometimes the archives & search results, pages.  Recently I got a call from a client that they had inserted an image into a post but it was not displaying.  Upon further investigation I found that the image that was attached to the post in question had originally been attached to another page.  Since bdw_get_images pulls images by looking for an attachment whose post_parent is the current post and since post_parent is only set for attachments when they are first added, this caused it not to find the image.  I decided it was time I wrote a newer function that would work regardless of whether the image was attached to any other posts.  At some point I think I’ll develop this into a legitimate plug-in with some additional options but here is a basic function you can add to your functions.php file in your theme.

Read more…

Categories: Wordpress Tags: , , , , ,