Support » Fixing WordPress » Adding Default Thumbnail

  • Wonder if someone to add to my code;

    I have a simple latest post in the sidebar, but have the an image, if saved in the custom field, for the post as the background of a div with rounded corners;

    It works well, but now I want to add a code to add a custom image if one isnt uploaded; Can someone help me out?


    $recentPosts = new WP_Query();
    while ($recentPosts->have_posts()) : $recentPosts->the_post(); ?>
    <?php $post_back = get_post_meta($post->ID, 'homepage-thumbnail', $single = true);?>
    <div class="newsimage" style="background: url('<?php echo $post_back; ?>') no-repeat; background-size: 100%;"></div>
    <span class="sidetitle"><a href="<?php the_permalink() ?>" rel="bookmark"
        title="Link to <?php the_title(); ?>">
    <?php the_title(); ?></a> </span><br />
    <?php echo get_excerpt(150); ?>
    <?php endwhile;?>
Viewing 6 replies - 1 through 6 (of 6 total)
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Adding Default Thumbnail’ is closed to new replies.