enter image description here

I have a simple question.

My wordpress theme has 2 pages: index.php and single.php. I've used the same code, but I had different results.



while(have_posts()) {

    <h3><?php the_title(); ?></h3>
    Posted by <?php the_author(); ?>
    <img src="<?php echo get_the_post_thumbnail_url(get_the_ID()); ?>" />
    <?php the_content(); 



In the code above, all the content shows up.



          $args = array(
            'posts_per_page' => 3,

          $blogposts = new WP_Query($args);

          while($blogposts->have_posts()) {


            <div class="col-lg-4">
              <div class="card" style="width: 18rem;">
                <img class="card-img-top" src="<?php echo get_the_post_thumbnail_url(get_the_ID()); ?>" alt="Img Post">
                <div class="card-body">
                  <h5 class="card-title"><?php the_title(); ?></h5>
                  <p class="card-text"><?php the_excerpt(); ?></p>
                  <a href="<?php the_permalink(); ?>" class="btn btn-primary">Leia mais</a>


In this case, all code is working, but the image didn't appeared.

What did I do wrong?


1 Answer 1


I've reached the "problem"

My theme had no "thumbnail" suport.

I just add the line add_theme_support( 'post-thumbnails' ); on funcions.php

Veja detalhes em https://codex.wordpress.org/Post_Thumbnails

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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