WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] has_post_thumbnail returns true no image, featured image (4 posts)

  1. Will004
    Member
    Posted 2 years ago #

    I made an export of a previous wordpress blog and imported it in to the new blog (new domain) same server. I used a plugin to retrieve all external images and then had it make local copies. The image links were all updated with the posts. I regenerated thumbnails and even tried to use auto featured image plugin but it doesnt make auto featured images.

    There is roughly 242 posts. They all have an image in the post apart from a handful of video posts.

    In index.php
    Within the following loop;
    <?php if(have_posts()) : ?><?php while(have_posts()) : the_post(); ?>

    I have the following code. If there is no thumbnail or image in the post then it will show a default image.

    The problem is, is that some posts are returning true but no image is being displayed. All video posts displays the default image, but all other posts contain an image. It only displays an image, if I physically edit the post and set a featured image.

    I don't really want to sift through 200+ posts to do this and no plugins are auto setting featured images. I've tried a few.

    <?php if(has_post_thumbnail()) {?>
                    <div class="img-thmb"><?php
    				echo the_post_thumbnail(array(165,130), array('border'=>0,'style'=>'border:1px solid #CCC;')); ?></div>
                    <?php } else {
    				echo '<div class="img-thmb"><img src="http://www.example.com/wp-content/themes/mytheme/images/mytheme_nothumb.png" height="130px;" border="0" width="165px" /></div>';
    				} ?>
  2. Will004
    Member
    Posted 2 years ago #

    I'm just re-uploading images.

  3. mortalwombat
    Member
    Posted 1 year ago #

    I'm curious, did you ever find a solution to this? I'm having the same problem.

  4. Ronald Huereca
    Member
    Posted 1 year ago #

    I found a solution based on this support thread. It requires the Auto Post Thumbnail plugin.

    Check out the GIST here: https://gist.github.com/4565131

    It first checks to see if there is a featured image. If not, it removes the thumbnail ID custom field, generates the thumbnail (if applicable), and displays it.

Topic Closed

This topic has been closed to new replies.

About this Topic