Skip to content

Instantly share code, notes, and snippets.

@baczoni
Created April 24, 2012 15:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save baczoni/2480946 to your computer and use it in GitHub Desktop.
Save baczoni/2480946 to your computer and use it in GitHub Desktop.
Wordpress: Enable featured image for posts/pages
<?php
add_theme_support( 'post-thumbnails' );
// This adds support for pages only:
add_theme_support( 'post-thumbnails', array( 'page' ) );
// And this adds support for posts only:
add_theme_support( 'post-thumbnails', array( 'post' ) );
// To get the thumbnail in your post, you add the following inside the loop:
if ( has_post_thumbnail() ) {
set_post_thumbnail_size( 400, 150 ); # width, height #
the_post_thumbnail();
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment