Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I need the ability to add an image to a page, like a featured image. How can I do that, and how do I get the featured image to display in page.php? It can be a plugin if what I am asking can't be done within Wordpress itself out of the box.

share|improve this question
    
custom fields? codex.wordpress.org/Custom_Fields –  Alexey Jan 30 '12 at 6:56

1 Answer 1

up vote 2 down vote accepted

Eek! A 33% acceptance rate isn't really going to do you any favours but lucky for you Wordpress' in-built post-thumbnail featured image functionality works for posts, custom post types and pages too.

Add the following line into your theme functions.php file:

add_theme_support( 'post-thumbnails', array( 'post', 'page' ) );

Then in your page.php file and I stress that this must be used within the page loop (not outside of it) the following function will show your featured image on a page if it has one assigned to it.

the_post_thumbnail()

Adding a featured image to a page is the same process as adding one to a post. On the page editing screen you will see a metabox with a link that says, 'Set a featured image' click that and you're good to go. No plugins required.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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