the_post_thumbnail not working

I’m not super familiar with wordpress, but I’ve been working on getting my layout written as a theme so I can use the wordpress platform. For some reason I can’t get the_post_thumbnail function working. I already added

add_theme_support( 'post-thumbnails' );

to my functions.php file and yes I did set a featured image and include the_post_thumbnail(); in the loop.

Read More

What am I doing wrong? I went as far as to go through the actual function and found that it is having problems with the $image variable in the wp_get_attachment_image() function while referencing the wp_get_attachment_image_src() function. $image is empty, when I’m guessing it shouldn’t be. It get’s the post_thumbnail id just fine though so I know it knows there’s an image set. It just won’t display the darn thing.

I’m writing myself a custom theme from scratch so functions.php only has add_theme_support( ‘post-thumbnails’ ); in it right now if you’re curious.

Edit:

Here’s my loop:

<?php if (have_posts()) : ?>
  <?php while (have_posts()) : the_post(); ?>
    <div class="home-entry clearfix" id="post-<?php the_ID(); ?>">

      <a href="<?php the_permalink() ?>" rel="bookmark" >
        <?php
        if (has_post_thumbnail()) {
          the_post_thumbnail(); 
        } else {
          echo '<img class="home-thumb trans-border" src="' . catch_first_image() . '" width="200px" height="150px" title="' . the_title() . '" />';
        }
        ?>
      </a>

      <div class="home-post">
        <div class="home-meta">Posted <?php the_time('M j, Y'); ?> - <?php the_category(' , ') ?> - <?php comments_popup_link('No Comments', '1 Comment', '% Comments'); ?></div>
        <h2 class="post-title">
          <a href="<?php the_permalink(); ?>" title="Permanent Link to <?php the_title_attribute(); ?>" rel="bookmark" class="title"><?php the_title(); ?></a>
          <a class="read" href="<?php the_permalink(); ?>" title="Read More">Read More</a>
        </h2>

        <div class="home-excerpt">
          <?php the_excerpt(); ?>
        </div>
      </div>



    </div>

  <?php endwhile; ?>    
  <?php echo paginate_links() ?> 
<?php else : ?>
  <h2>Nothing Found</h2>
<?php endif; ?> 

Continued:

So I went and found a theme with featured image support and copied that part of the loop exactly and still nothing:

<?php if(has_post_thumbnail()) {
echo '<span class="thumbnail"><a href="'; the_permalink(); echo'">';the_post_thumbnail(array(100,100)); echo '</a></span>';

 } else {

                  $image = evlget_first_image(); 

                    if ($image):
                  echo '<span class="thumbnail"><a href="'; the_permalink(); echo'"><img src="'.$image.'" alt="';the_title();echo'" /></a></span>';
                   endif;
           } ?>

So what the heck could it be? I’m so confused…

Related posts

Leave a Reply

2 comments