I've a problem with the loop in wordpress, my website is a feed aggregator and basically I want my website to display an image if the feed contains an image or a specified image if it doesn't. here's the code I actually use:
<?php $enclosure = get_post_meta($post->ID , 'enclosure', $single = true); ?>
<?php $image=explode(chr(10),$enclosure); ?>
<?php if(!is_null($image)) : ?>
<div class="left">
<a href="<?php the_permalink() ?>" rel="bookmark" title="Link all'articolo: <?php the_title_attribute(); ?>"><img src="<?php echo $image[0]; ?>" alt="<?php the_title_attribute(); ?>" style="width:150px; text-align:center;"/></a>
</div>
<?php endif; ?>
It works very well but now I want to show a "default" image if the feed doesn't provide one, I tried in this way:
<?php $enclosure = get_post_meta($post->ID , 'enclosure', $single = true); ?>
<?php $image=explode(chr(10),$enclosure); ?>
<?php if(!is_null($image)) : ?>
<div class="left">
<a href="<?php the_permalink() ?>" rel="bookmark" title="Link all'articolo: <?php the_title_attribute(); ?>"><img src="<?php echo $image[0]; ?>" alt="<?php the_title_attribute(); ?>" style="width:150px; text-align:center;"/></a>
</div>
<?php else : ?>
<div class="left">
<a href="<?php the_permalink() ?>" rel="bookmark" title="Link all'articolo: <?php the_title_attribute(); ?>"><img src="PATH TO THE DEFAULT IMAGE" alt="<?php the_title_attribute(); ?>" style="width:150px; text-align:center;"/></a>
</div>
<?php endif; ?>
But it doesn't work... Where am I wrong? Sorry for my english!
Thanks!