Custom post thumbnails to WordPress posts

You can define a custom post thumbnail by adding following code to your WP theme. For this you need to create a custom field called post-img add a URL to your image.

 
	<?php
		$postimageurl = get_post_meta($post->ID, 'post-img', true);
		if ($postimageurl) {
	?>
	<a href="<?php the_permalink(); ?>" rel="bookmark"><img src="<?php echo $postimageurl; ?>" alt="<?php the_title(); ?>" width="150" height="150" /></a>
	<?php } else { ?>
	<a href="<?php the_permalink(); ?>" rel="bookmark"><img src="<?php bloginfo('template_url'); ?>/images/my-default-img.png" alt="<?php the_title(); ?>" width="210" height="210" /></a>
	<?php } ?>

Related posts:

HTML5 page structure

HTML5 offers more powerful structure comparing to older versions of Html. There are many new …


Partner with Us

We are providing an exclusive partnership offer to individuals and companies who are interested in setting up their own web design & development company. For more information about how to partner with us, please contact us