Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to call featured image in WordPress

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 307
    Comment on it

    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 .

    1. <?php
    2. if( have_posts() ) {
    3. while( have_posts() ) { // this query show the posts
    4. the_post();
    5. $largeImg = wp_get_attachment_image_src( get_post_thumbnail_id(), 'large' ); // calling the feature image with large size
    6. // custom content ?>
    7. <img class="thumbnails" src="<?php echo $largeImg[0]; ?>" /> // display the feature image
    8. <?php the_content(); ?> // display the post content
    9. <?php
    10. }
    11. } else {
    12. echo "No posts found!!";
    13. }
    14. ?>

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Reset Password
Fill out the form below and reset your password: