Twenty Ten child theme – getting post thumbnails working
-
I’m new to WordPress and am creating my first WP theme as a Twenty Ten child theme. I want to show a post thumbnail on the homepage and on the category pages, and have tried several tutorials and just can’t get them to show up – I must be missing something!
Most recently I tried this tutorial: http://themesforge.com/wordpress/add-new-native-wordpress-post-thumbnails-to-your-theme/, putting the code for index.php in loop.php as I am using version 3 of WordPress.
My child theme’s functions.php looks like this:
<?php /* switch on support for post thumbnails - WordPress 2.9 onwards */ if ( function_exists( 'add_theme_support' ) ) { // Added in 2.9 add_theme_support( 'post-thumbnails' ); set_post_thumbnail_size( 100, 100, true ); // Normal post thumbnails add_image_size( 'hp-post-thumbnail', 200, 200, true ); // Homepage thumbnail size add_image_size( 'single-post-thumbnail', 300, 9999 ); // Permalink thumbnail size } ?>
The relevant section of loop.php:
<?php /* How to display all other posts. */ ?> <?php else : ?> <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentyten' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php the_title(); ?></a></h2> <div class="entry-meta"> <?php twentyten_posted_on(); ?> </div><!-- .entry-meta --> <?php if ( is_archive() || is_search() ) : // Only display excerpts for archives and search. ?> <div class="entry-summary"> <?php the_excerpt(); ?> </div><!-- .entry-summary --> <?php else : ?> <div class="entry-content"> <?php if ( function_exists( 'add_theme_support' ) ) : ?> <?php if ( has_post_thumbnail() ) : ?> <div class="postthumb"> <?php the_post_thumbnail( 'hp-post-thumbnail' ); ?> </div> <?php endif; ?> <?php endif; ?> <?php the_content( __( 'Continue reading <span class="meta-nav">→</span>', 'twentyten' ) ); ?> <?php wp_link_pages( array( 'before' => '<div class="page-link">' . __( 'Pages:', 'twentyten' ), 'after' => '</div>' ) ); ?> </div><!-- .entry-content --> <?php endif; ?>
Can anyone please tell me what I have done wrong, or perhaps a better way of doing it? Thank you for your time.
- The topic ‘Twenty Ten child theme – getting post thumbnails working’ is closed to new replies.