WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

so, i wanted to thumbnails in my query and i came across add_theme_support, it says you have to have that to enable actions such as thumbnail, so i put the following in my functions

function pippin_add_thumbnail_support() {
    if(!current_theme_supports('post-thumbnails')) {
add_action('init', 'pippin_add_thumbnail_support');

Even after that code, my query doesn't generate a post thumbnail, when my query is

            $posts = get_posts(array('posts_per_page' => 4));
            foreach ($posts as $post) {
                if( has_post_thumbnail()){

                echo $post->post_title;

Am i missing something, or doing something wrong?

share|improve this question
Have you put the 1st code in functions.php file? Also this may not directly work for the posts already added. You need to add/update the posts again to generate the required images or you can use regenerate thumbnails plugins to generate the images automatically. – Chittaranjan Dec 14 '13 at 11:22
@Chittaranjan yes do have it in my functions.php , but i think it was add/update the posts, as you mention. it worked. – Nofel Dec 14 '13 at 11:43
Since the above tip worked for you, I have added that as an answer below and you can accept that. – Chittaranjan Dec 14 '13 at 14:41
up vote 0 down vote accepted

You need to echo the get_post_thumbnail in order for it to output.

echo get_the_post_thumbnail($post->ID,'thumbnail');
share|improve this answer

If you have images already added before adding the above piece of code, then you need to update the posts again to generate the required images. It will automatically work for all those posts which will be added from now.

If you have large number of images, then you can use Regenerate Thumbnails plugin to generate the images automatically.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.