WordPress.org

Ready to get started?Download WordPress

Forums

get_the_post_thumbnail (3 posts)

  1. ArdorEdor42
    Member
    Posted 2 years ago #

    Hi I'd like to modify this code to check to see if there's a featured thumbnail, and if no thumbnail use a default image. Any ideas?

    <?php $nextPost = get_next_post(false);
    if($nextPost) { ?>
    <div class="nav-box-next">
    <div class="nexttitleText">Next Post </div>
    <?php $nextthumbnail = get_the_post_thumbnail($nextPost->ID,thumbnail); ?>
    <?php next_post_link('%link',"$nextthumbnail", false);?>
    <p><?php next_post_link('%link',"%title", false);?> </p>
    </div> <?php } ?>

  2. ArdorEdor42
    Member
    Posted 2 years ago #

    The code above works well, but I can't figure out how to add an if statement do essentially this:

    <?php if ( has_post_thumbnail() ) {
    the_post_thumbnail('thumbnail');}

    else { ?>
    <img src="<?php bloginfo('template_directory'); ?>/images/default-image.jpg" />
    <?php } ?>

  3. pbeckley
    Member
    Posted 1 year ago #

    nm

Topic Closed

This topic has been closed to new replies.

About this Topic