I am making a template page name new_template.php,here i want to add a feature image source. how to add featured image source on this blank page. and when i add featured image then the description content is not displaying. thanks


Page's don't by default have a "Featured Image". If you've found a plugin to do that, then to output the Featured Image use the following function:


You can read more about it in the WordPress Codex here.

There are various other functions that will return the image markup (get_the_post_thumbnail ()), or just the Featured Image source (wp_get_attachment_image_src()). Again, look in the Codex for detailed instructions on how to use these functions.

| improve this answer | |
  • okey .. if i have to display content as well then what code need to write ..thanks for your reply – user3060132 Dec 6 '13 at 7:00
  • ohh cool .. its working fine... the_post_thumbnail() helps me to display the feature image. thanks once again :) – user3060132 Dec 6 '13 at 7:04

Here is an untested function that will allow you to paste this code in The Loop or actually get the source of a post thumbnail via get_the_ID. You could also tweak it for custom sizes. Just paste this in your functions.php


function get_featured_image_src($ID){
        $FI = wp_get_attachment_image_src( get_post_thumbnail_id($ID), 'full' );
    } else {
        $FI = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full' );
    return $FI[0];


Then echo it.

<?php echo get_featured_image_src(); /* OR get_featured_image_src( get_the_ID() ); when not in loop */ ?>
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.