• Resolved sollers

    (@sollers)


    Hello,

    I’m trying to insert link to my thumbnail images, but I’m stuck with elseif structure.

    <?php
    if ( has_post_thumbnail() ) {
    <a href=<?php the_permalink() ?>"><img src="<?php the_post_thumbnail(); ?>" width="50x" height="50px" title="<?php the_title(); ?>" /></a>
    } else
    	<a href=<?php the_permalink() ?>"><img src="image.png" width="50x" height="50px" title="<?php the_title(); ?>" /></a>
    
    ?>

    I know this is childishly simple to some of you, but I’m hitting head against a wall.

    Thank you for help!

Viewing 2 replies - 1 through 2 (of 2 total)
  • switching from php to html and back can be tricky:

    <?php
    if( has_post_thumbnail() ) { ?>
    <a href=<?php the_permalink(); ?>"><img src="<?php the_post_thumbnail(); ?>" width="50x" height="50px" title="<?php the_title(); ?>" /></a>
    <?php } else { ?>
    <a href=<?php the_permalink(); ?>"><img src="image.png" width="50x" height="50px" title="<?php the_title(); ?>" /></a>
    <?php } ?>
    Thread Starter sollers

    (@sollers)

    Thank you alchymyth, works like a charm!

    Notice: If anyone issues a problem with no image, the_post_thumbnai already outputs the img embed code.

    Change 3rd line to
    <a href=<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a>

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘the_post_thumbnail if/else’ is closed to new replies.