I am try to insert link to my thumbnail images, the link is hyperlink with post. When i put this code inside the loop then instead of showing the first image, first show the second image (template_url)
<a href="<?php the_permalink() ?>" class="alignnone" title="<?php the_title(); ?>">
<?php if (has_post_thumbnail()) : ?>
<a href="<?php the_permalink(); ?>" title="<?php the_title();?>"><?php the_post_thumbnail(); ?></a>
<?php else : ?>
<img src="<?php bloginfo('template_url'); ?>/images/noimage.jpg" width="213" height="187" alt=""/>
<?php endif; ?>
</a>
The code of the tempate :
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div <?php post_class() ?> id="post-<?php the_ID(); ?>=">
<div class="item">
<ul>
<li>
<a href="<?php the_permalink() ?>" class="alignnone" title="<?php the_title(); ?>">
<a href="<?php the_permalink(); ?>" title="<?php the_title();?>">
<?php if (has_post_thumbnail()) : ?>
<?php the_post_thumbnail(); ?></a>
<?php else : ?>
<img src="<?php bloginfo('template_url'); ?>/images/noimage.jpg" width="213" height="187" alt=""/>
<?php endif; ?>
</a>
<div id="info">
<div class="title_album"> <strong>Άlbum : </strong> <?php print_custom_field('title_album'); ?><br /> </div>
<div class="number_photos"><strong>Photos : </strong> <?php print_custom_field('Number_photos'); ?><br /> </div>
</div>
</li>
</ul>
</div> <!-- end item -->
</div> <!-- END div class post -->
Even if this part of code, the result is the same..
<?php echo '<a href="', get_permalink(), '">';
if (has_post_thumbnail())
{the_post_thumbnail();}
else {echo'<img src="', get_bloginfo('template_directory'), '/images/noimage.jpg', '" width="213" height="187" alt="thumbnail" />';}
echo '</a>'; ?>