The Support Forums will be in read-only mode for a scheduled maintenance window on 01 September 2016 14:00 UTC - 20:00 UTC. More information.

[resolved] How to show default placeholder image without link (2 posts)

  1. vikkineal
    Posted 4 years ago #

    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');
        echo '<img src="http://2.bp.blogspot.com/-DXmE0_mUAtg/TV5XC1JDN2I/AAAAAAAAAvc/_jdxdJATQHQ/s320/guard-cat.jpg"/>';
  2. vikkineal
    Posted 4 years ago #

    <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; ?>

Topic Closed

This topic has been closed to new replies.

About this Topic