WordPress.org

Ready to get started?Download WordPress

Forums

[Theme: Twenty Twelve] problem with setting up thumbnails + excerpt on index? (9 posts)

  1. ricardouk
    Member
    Posted 2 years ago #

    Hi everyone!

    Ive replaced my website theme with a 2012 child theme, there arent many child themes yet available so i decided to make one, googled around and managed to get started and its nearly finished.

    i followed another user advice and applied the following changes:
    changed:
    <?php if ( is_search() ) : // Only display Excerpts for Search ?>

    to:
    <?php if ( is_search() || is_home() ) : // Only display Excerpts for Search and Index ?>

    then i added the post thumbnail code before the code above so that i could have a thumb+excerpt on index page, when i used firebug i noticed that when loading the index page both the thumb and the image that shows up on single post pages get loaded.

    it sounds confusing so ill share the url:
    http://www.ricardouk.com

    you'll see 5 thumbs but firebug says 10 images are being loaded.

    Can anyone help?

    Thanks

  2. Andrew
    Forum moderator
    Posted 2 years ago #

    Where does firebug show 10 images are loading?
    I've inspected the first thumbnail in post, "Atif Aslam – Doorie (remix) – legendado" and can only see that thumbnail.

  3. ricardouk
    Member
    Posted 2 years ago #

    yes, thats right my bad, thats a video post...have a look at second one

    heres a secreenshot:
    http://www.ricardouk.com/2012.jpg

  4. ricardouk
    Member
    Posted 2 years ago #

    i tried pingdoom just to be sure it wasnt firebug playing up and i confirmed the problem, there are 2 image requests for the same image on index page for each post, teh thumb and normal "heavy" version meant to be seen on single post.

  5. you have hidden the originally existing feature image with this css in style.css of your child theme:

    .entry-header img.wp-post-image {
    display: none;
    }

    if you look at the html code of the first post of the index page:

    <article id="post-13539" class="post-13539 post type-post status-publish format-standard hentry category-cinema category-videoclips">
    				<header class="entry-header">
    			<img width="50" height="50" src="http://www.ricardouk.com/wp-content/uploads/2010/04/video-50x50.jpg" class="attachment-post-thumbnail wp-post-image" alt="video" title="video" />						<h1 class="entry-title">
    				<a href="http://www.ricardouk.com/2012/11/atif-aslam-doorie-remix-legendado.html" title="Permalink to Atif Aslam – Doorie (remix) – legendado" rel="bookmark">Atif Aslam – Doorie (remix) – legendado</a>
    			</h1>
    										<div class="comments-link">
    					<a href="http://www.ricardouk.com/2012/11/atif-aslam-doorie-remix-legendado.html#respond" title="Comentário em Atif Aslam – Doorie (remix) – legendado"><span class="leave-reply">Comentar</span></a>				</div><!-- .comments-link -->
    					</header><!-- .entry-header -->
    
    				<div class="entry-summary">
    			<img width="100" height="100" src="http://www.ricardouk.com/wp-content/uploads/2010/04/video.jpg" class="alignleft wp-post-image" alt="video" title="video" /><p>Atif Aslam nasceu em 1983 no Paquistão e com apenas 29 anos é um dos cantores e compositores mais requisitados em Bollywood, as músicas dos seus albums são muito requisitadas para fazerem parte das bandas sonoras dos filmes em Bollywood, fica aqui a remix de uma música que faz parte<a href="http://www.ricardouk.com/2012/11/atif-aslam-doorie-remix-legendado.html">&nbsp;&nbsp;[Ler mais...]</a></p>
    		</div><!-- .entry-summary -->

    you will see two featured images geting loaded.

    the original code of the first one is here in content.php:

    <header class="entry-header">
    			<?php the_post_thumbnail(); ?>
    			<?php if ( is_single() ) : ?>
    			<h1 class="entry-title"><?php the_title(); ?></h1>
    			<?php else : ?>
  6. ricardouk
    Member
    Posted 2 years ago #

    Sorry but im lost, im a begginer with child themes... i used css because i didnt want the featured image to be shown above the title so by googling around i used the following on a child theme.

    http://pastebin.com/cHihuYXL

    how do i achieve that thumb (left) + excerpt (right) on index page without loading so many images?

    sorry but im just starting with child themes...im still learning

  7. ricardouk
    Member
    Posted 2 years ago #

    ive done it, heres the code im using now, does anyone have better ideas?

    <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    		<?php if ( is_sticky() && is_home() && ! is_paged() ) : ?>
    		<?php _e( 'Featured post', 'twentytwelve' ); ?>
    		<?php endif; ?>
    		<header class="entry-header">
    			<?php the_post_thumbnail(); ?>
    			<?php if ( is_single() ) : ?>
    			<h1 class="entry-title"><?php the_title(); ?></h1>
    			<?php else : ?>
    			<h1 class="entry-title">
    				<a href=""<?php">" title="<?php echo esc_attr( sprintf( __( 'Permalink to %s', 'twentytwelve' ), the_title_attribute( 'echo=0' ) ) ); ?>" rel="bookmark"><?php the_title(); ?></a>
    			</h1>
    			<?php endif; // is_single() ?>
    			<?php if ( comments_open() ) : ?>
    				<div class="comments-link">
    					<?php comments_popup_link( '<span class="leave-reply">' . __( 'Comentar', 'twentytwelve' ) . '</span>', __( '1 comentário', 'twentytwelve' ), __( '% Comentários', 'twentytwelve' ) ); ?>
    				</div><!-- .comments-link -->
    			<?php endif; // comments_open() ?>
    		</header><!-- .entry-header -->
    
    		<?php if ( is_search() || is_home() ) : // Only display Excerpts for Search and Index ?>
    		<div class="entry-summary">
    			<?php the_post_thumbnail(array( 100,100 ), array( 'class' => 'alignleft' )); ?><?php the_excerpt(); ?>
    		</div><!-- .entry-summary -->
    		<?php else : ?>
    		<div class="entry-content">
  8. i used css because i didnt want the featured image to be shown above the title

    that means that the image is loaded first, and then hidden with css;

    if you do not want the image to load, remove this line (this is line 6 in your last posted code):

    <?php the_post_thumbnail(); ?>

    from this section:

    <header class="entry-header">
    			<?php the_post_thumbnail(); ?>
    			<?php if ( is_single() ) : ?>
  9. ricardouk
    Member
    Posted 2 years ago #

    thanks

Topic Closed

This topic has been closed to new replies.

About this Topic