Enable post thumbnails for a Wordpress theme


/ Published in: PHP
Save to your folder(s)

This snippet adds support for post thumbnails (a.k.a. 'featured images') to a Wordpress theme. It also adds an additional image size for image thumbnails, hard cropped. This second step is optional.

Add this snippet to your WP theme's functions.php file.


Copy this code and paste it in your HTML
  1. /**
  2.  * Enable post thumbnails.
  3.  */
  4. if ( function_exists( 'add_theme_support' ) ) {
  5. add_theme_support( 'post-thumbnails', array( 'project' ) ); // Add support for posts
  6. add_image_size( 'large-feature-image', 715, 402, true ); // large size, hard crop mode
  7. }

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.