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 would like to use my excerpt field to display a different image for each post to represent that post. For instance a post about a new album instead of having a title/text excerpt would simply be an image of that album.

I create i new post like :

    <img class="alignnone size-thumbnail wp-image-1078" title="" src="http://localhost/mywebsite/wp-content/uploads/2013/01/22224-213x187.png" alt="" width="213" height="187" />

    <!--more-->

TEST
    <img class="alignnone size-thumbnail wp-image-1078" title="" src="http://localhost/mywebsite/wp-content/uploads/2013/01/22224-213x187.png" alt="" width="213" height="187" />

single-photos.php :

<div <?php post_class() ?> id="post-<?php the_ID(); ?>=">
    <?php   echo get_the_excerpt(); ?>                  
</div>  

With this code, displays only the text, and not the image. I want to display only image or gallery. How to do that? Thanks.

share|improve this question
    
why are you using get_the_excerpt() on a single post page (or custom post type)? I assume that that is a single post type page since you are referencing single-photos.php. –  WP Themes Jan 31 '13 at 1:05

2 Answers 2

To display post's featured image, you need to use the the post thumbnail

codex - the post thumbnail

you can use it and get the desired size like this

the_post_thumbnail('thumbnail');       // Thumbnail (default 150px x 150px max)
the_post_thumbnail('medium');          // Medium resolution (default 300px x 300px max)
the_post_thumbnail('large');           // Large resolution (default 640px x 640px max)
the_post_thumbnail('full');            // Full resolution (original size uploaded)

the_post_thumbnail( array(100,100) );  // Other resolutions
share|improve this answer
    
i don't want to enable the image which is in the content, but only the image/gallery which is in the excerpt. –  MikeD Jan 30 '13 at 21:58
    
I enable the excerpt fields and i grab inside the gallery code ex [oqeygallery id=1], when i publish the post, the gallery doesn't work but only <img>, any idea? –  MikeD Jan 31 '13 at 16:23

when you edit the post, enable the Excerpt metabox. This is done by bringing down the screen options tab - look for it in the upper right hand corner - and check Excerpt. This will display a new metabox called "Excerpt" somewhere below the content editor.

Put your <img> there.

Anyway, what you probably want is to implement post formats.

share|improve this answer
    
i enable the Excerpt field, and at this time i try to use some plugins with the using of image gallery/slider. I hope that i have news and updating in few hours. Thanks. –  MikeD Jan 31 '13 at 1:21

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.