Add Post Class if Post has thumbnail

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.  
  8.  
  9.  
  10.  
<?php
// add class if post has thumbnail
function has_thumb_class($classes) {
	global $post;
	if( has_post_thumbnail($post->ID) ) { $classes[] = 'has_thumb'; }

		return $classes;
}
add_filter('post_class', 'has_thumb_class');
?>

Instructions:

Add this snippet to your functions.php file to add a post class to any post that uses a featured image.


Related links:
http://codex.wordpress.org/Post_Thumbnails
Share this snippet

If you like this snippet, share it with friends!