• Resolved Blicc

    (@blicc)


    Hello,

    I have tried to get post thumbnails to my TwentyTen child theme. I used the instructions you can find at https://www.keleko.com/2010/setting-up-post-thumbnails-in-wordpress-3-0-with-twenty-ten/ .

    Now the post thumbnail works on a single article page but not on the index site. Below you can find my code:

    functions.php

    <?php
    
    add_action( 'init', 'mytheme_setup' );
    
    function mytheme_setup() {
        set_post_thumbnail_size( 100, 100, true );
        add_image_size( 'single-post-thumbnail', 250, 250 );
    }
    
    ?>

    loop.php

    <?php if ( is_archive() || is_search() ) : // Only display excerpts for archives and search. ?>
                <div class="entry-summary">
                    <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_post_thumbnail(); ?></a>
                    <?php the_excerpt(); ?>
                </div><!-- .entry-summary -->
        <?php else : ?>
                <div class="entry-content">
                    <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_post_thumbnail(); ?></a>
                    <?php the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentyten' ) ); ?>
                    <?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'twentyten' ), 'after' => '</div>' ) ); ?>
                </div><!-- .entry-content -->
        <?php endif; ?>

    loop-single.php

    <div class="entry-content">
    <?php the_post_thumbnail( 'single-post-thumbnail' ); ?>
    						<?php the_content(); ?>
    						<?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'twentyten' ), 'after' => '</div>' ) ); ?>
    					</div><!-- .entry-content -->

    Now my question: What must I do to get this to work?

    Thanks for answers!

Viewing 4 replies - 1 through 4 (of 4 total)
  • You need to add <?php the_post_thumbnail( 'single-post-thumbnail' ); ?> to loop.php

    Thread Starter Blicc

    (@blicc)

    Now my loop.php looks like this:

    <?php if ( is_archive() || is_search() ) : // Only display excerpts for archives and search. ?>
                <div class="entry-summary">
                    <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_post_thumbnail( 'single-post-thumbnail' ); ?></a>
                    <?php the_excerpt(); ?>
                </div><!-- .entry-summary -->
        <?php else : ?>
                <div class="entry-content">
                    <a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_post_thumbnail( 'single-post-thumbnail' ); ?></a>
                    <?php the_content( __( 'Continue reading <span class="meta-nav">&rarr;</span>', 'twentyten' ) ); ?>
                    <?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'twentyten' ), 'after' => '</div>' ) ); ?>
                </div><!-- .entry-content -->
        <?php endif; ?>

    But it doesn’t work either…

    Hey Blicc,

    Normally TwentyTen is already setup for Thumbnails…

    This one is modified, but you should have something similar already in your functions.php file :
    set_post_thumbnail_size( 300, 150, true );

    Then I’ve got my image set up to insert with a condition just in case there isn’t a thumbnail available (yes, like esmi says, must be in the loop, but it looks like you already were) :

    <?php if (has_post_thumbnail()) { the_post_thumbnail(); }?>

    Voilà, hope that helps!

    Thread Starter Blicc

    (@blicc)

    Now it works! I have just put the code to the wrong section of loop.php…

    Sorry ??

    Thanks for helping!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Post thumbnails in TwentyTen Child Theme (WordPress 3.1)’ is closed to new replies.