Code for custom field Image in recent post List

<h3>Recent Post</h3>
<div>

<!– use a custom field for image , Here the custom field name is = “newReleaseThumb” –>

<?php $myposts = get_posts(‘numberposts=5&offset=1′);foreach($myposts as $post) :? >
<div style=” width:100%; float:left; border:#FF0000 0px solid; padding: 5px; margin-bottom:2px; background:#0000FF;”>
<div style=”width:95px; float:left;”>
<?php $thumbnail = get_post_meta($post->ID, ‘newReleaseThumb’, true); ?> <a href=”<?php the_permalink() ?>” title=”<?php the_title_attribute(); ?>”> <img src=”<?php echo $thumbnail; ?>” /></a>
</div>
<div style=”width:95px; padding-left:5px; float:right;”><a href=”<?php the_permalink() ?>” rel=”bookmark” title=”Permanent Link to <?php the_title_attribute(); ?>”><?php the_title();?></a>
</div>
</div>
<?php endforeach; ?>
</div>

<!– ———————————

IF YOU NEED A FIXED  CATEGORY POST USE IT
—————————————————
here I use a category named “New Relese”  –>

<h3>New Release</h3>
<div>

<!– use a custom field for image , Here the custom field name is = “newReleaseThumb” –>
<?php $my_query = new WP_Query(‘category_name=New Release&showposts=4′); ?>
<?php while ($my_query->have_posts()) : $my_query->the_post(); {?>

<div style=” width:100%; float:left; border:#FF0000 0px solid; padding: 5px; margin-bottom:2px; background:#0000FF;”>
<div style=”width:95px; float:left;”>
<?php $thumbnail = get_post_meta($post->ID, ‘newReleaseThumb’, true); ?> <a href=”<?php the_permalink() ?>” title=”<?php the_title_attribute(); ?>”> <img src=”<?php echo $thumbnail; ?>” /></a>
</div>
<div style=”width:95px; padding-left:5px; float:right;”><a href=”<?php the_permalink() ?>” rel=”bookmark” title=”Permanent Link to <?php the_title_attribute(); ?>”><?php the_title();?></a>
</div>
</div>
<?php } endwhile; ?>

</div>

Leave a Reply

%d bloggers like this: