Skip to content

Instantly share code, notes, and snippets.

@claudiosanches
Created December 5, 2012 23:51
Show Gist options
  • Save claudiosanches/4220614 to your computer and use it in GitHub Desktop.
Save claudiosanches/4220614 to your computer and use it in GitHub Desktop.
WordPress - Thumbnails
<?php
// Adiciona suporte para os thumbnails
add_theme_support( 'post-thumbnails' );
// Adiciona os tamanhos que vai usar
// No exemplo ela chama 'thumb_home' e tem largura e altura iguais a 150px e faz crop
add_image_size( 'thumb_home', 150, 150, true );
// Mais exemplos de como adicionar os tamanhos:
// http://codex.wordpress.org/Function_Reference/add_image_size
<?php
// E aqui para chamar a thumbnail se o post tiver:
if ( has_post_thumbnail() ) {
the_post_thumbnail( 'thumb_home' );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment