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
    • 288
    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 .

    <?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)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: