In WordPress there is featured image for Post and Pages and Custom Post types.
To get the feature image of an post or page or custom post type use the following code.
To get the feature image of an post or page or custom post type use the following code.
<?php if (has_post_thumbnail( $post->ID ) ):
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' );
endif;
?>
Now in $image you have all the feature image information. To display the image you can do it as follows:
<img src="<?php echo $image[0]; ?>" />
And you are done. Now feature image will be displayed.
No comments:
Post a Comment