If we are making a custom wordpress theme , we can call any feature image attached with any post or any custom post. Wordpress have by default option for feature image. We can upload the feature image to any post or any custom posts.
We can call the feature image in any post where we want to show that posts in which feature image is attached.
For calling featured image, use the below code .
<?php
if( have_posts() ) {
while( have_posts() ) { // this query show the posts
the_post();
$largeImg = wp_get_attachment_image_src( get_post_thumbnail_id(), 'large' ); // calling the feature image with large size
// custom content ?>
<img class="thumbnails" src="<?php echo $largeImg[0]; ?>" /> // display the feature image
<?php the_content(); ?> // display the post content
<?php
}
} else {
echo "No posts found!!";
}
?>
0 Comment(s)