Post Thumbnails

//add this to the functions.php file
add_theme_support( 'post-thumbnails' );

//add this to the functions.php file this to only add to page templates not posts
add_theme_support( 'post-thumbnails', array( 'page' ) );

//Show the thumbnail
<?php the_post_thumbnail( 'thumbnail' ); ?>

//Show the thumbnail as medium
<?php the_post_thumbnail( 'medium' ); ?>

//Change thumbnail size

if ( function_exists( 'add_image_size' ) ) {
add_image_size( 'game-thumb', 100, 74 ,true);//true arg is for hard crop
}

//Use a conditional

<?php if ( has_post_thumbnail() ) the_post_thumbnail('game-thumb'); ?>

//Change the title attribute

<?php the_post_thumbnail( 'post-thumbnail', array( 'title' => $title, 'alt' => $title ) ); ?>

0 Comments

You must be logged in to post a comment.