• Resolved vikkineal

    (@vikkineal)


    Hi there

    Can anyone help?

    I’m trying to show a default placeholder image on my posts when the user hasn’t uploaded an image.

    I have the below code BUT i need to rewrite it so that the link to the lightbox isn’t applied to the placeholder image – only the uploaded image.

    Unfortunately my PHP isn’t great at all so would appreciate some help..

    <div class="imageContainer"><a href="<?php the_permalink(); ?>">
            <?php if ( has_post_thumbnail($post->ID)) {
        echo get_the_post_thumbnail($post->ID, 'size-2');
     }else{
        echo '<img src="http://2.bp.blogspot.com/-DXmE0_mUAtg/TV5XC1JDN2I/AAAAAAAAAvc/_jdxdJATQHQ/s320/guard-cat.jpg"/>';
     }?>
            </a></div>
Viewing 1 replies (of 1 total)
  • Thread Starter vikkineal

    (@vikkineal)

    <div class="imageContainer">
        <?php if ( has_post_thumbnail() ) : ?>
            <a href="<?php the_permalink(); ?>"><?php the_post_thumbnail('size-2'); ?></a>
        <?php else : ?>
            <img src="<?php echo get_bloginfo( 'stylesheet_directory' ); ?>/images/shared/placeholder.jpg" />
        <?php endif; ?>
    </div>
Viewing 1 replies (of 1 total)
  • The topic ‘How to show default placeholder image without link’ is closed to new replies.