Forums

[resolved] Post thumbnails in TwentyTen Child Theme (WordPress 3.1) (5 posts)

  1. Blicc
    Member
    Posted 1 year ago #

    Hello,

    I have tried to get post thumbnails to my TwentyTen child theme. I used the instructions you can find at http://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!

  2. esmi
    Theme Diva & Forum Moderator
    Posted 1 year ago #

    You need to add <?php the_post_thumbnail( 'single-post-thumbnail' ); ?> to loop.php

  3. Blicc
    Member
    Posted 1 year ago #

    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...

  4. jennybeaumont
    Member
    Posted 1 year ago #

    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!

  5. Blicc
    Member
    Posted 1 year ago #

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

    Sorry :)

    Thanks for helping!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.