I am using wordpress 3.1 and when I use the featured image metabox to upload sometimes I see in my posts the image as part of the content and sometimes the header image changes as well. I cannot understand what is the reason. Any help will be appreciated.
I am using
if ( has_post_thumbnail() )
{ // check if the post has a Post Thumbnail assigned to it.
the_post_thumbnail();
}
Update
sorry i got confused with the editor. anyway what i need right now is to display the thumbnail in a size of 300×300 but have a larger image to display when the user clicks on the thumbnail. i saw the loop-attachment.php and i think i have to use this one.
<?php $attachment_page = get_attachment_link( $attachment_id ); ?>
<?php $thumb=get_the_post_thumbnail(); ?>
<a href="<?php echo $attachment_page; ?>">
<?php the_post_thumbnail();?>
</a>
but it is not working. i dont know if i have to post it as a new question also.
Assuming you are using Twenty Ten, Twenty Eleven, or one of the several Themes that derive Post Thumbnail (i.e. “featured image”) feature handling from either of these Themes:
EDIT
To have a custom image size, such as 300×300, you can use
add_image_size()
. For example, add the following tofunctions.php
:add_image_size( 'single-post-image', 300, 300, true );
Then, in
single.php
, you can add:<?php the_post_thumbnail( 'single-post-image' ); ?>
And your 300x300px image will be inserted wherever you place it.
(Note: you may need to regenerate existing Thumbnails.)
EDIT
To link your displayed, custom-sized featured image to its attachment-page view, you need to use
get_attachment_link()
. Insingle.php
: