WordPress.org

Ready to get started?Download WordPress

Forums

Post Images duplicating on top of my header....? (6 posts)

  1. Ncastro340
    Member
    Posted 3 years ago #

    Can anyone tell me why the first imamge of a post is duplicating above my header..?

    My Site is Here

  2. esmi
    Forum Moderator
    Posted 3 years ago #

    Because that's how the Twenty Ten theme works. It uses the first image in a post as the header image in a single post page.

  3. Ncastro340
    Member
    Posted 3 years ago #

    how can I prevent this from happening?

  4. esmi
    Forum Moderator
    Posted 3 years ago #

    Create a child theme, copy header.php from the parent into the child and then edit the header,php file in the child theme to remove the post image on single post pages.

  5. Ncastro340
    Member
    Posted 3 years ago #

    Thanks, once I removed this code in header.php the images were no longer there.

    <?php
    					// Check if this is a post or page, if it has a thumbnail, and if it's a big one
    					if ( is_singular() &&
    							has_post_thumbnail( $post->ID ) &&
    							( /* $src, $width, $height */ $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'post-thumbnail' ) ) &&
    							$image[1] >= HEADER_IMAGE_WIDTH ) :
    						// Houston, we have a new header image!
    						echo get_the_post_thumbnail( $post->ID, 'post-thumbnail' );
    					else : ?>
    						<img src="<?php header_image(); ?>" width="<?php echo HEADER_IMAGE_WIDTH; ?>" height="<?php echo HEADER_IMAGE_HEIGHT; ?>" alt="" />
    
    					<?php endif; ?>
  6. esmi
    Forum Moderator
    Posted 3 years ago #

    Warning: If you amended the Twenty Ten theme itself, your customisations will be over-written the next time you upgrade WordPress or the theme. For this reason, it is recommended that you consider creating a child theme for your customisations.

Topic Closed

This topic has been closed to new replies.

About this Topic