Add a Class to a Featured Image in WordPress

You can add a CSS class to a featured image in WordPress using an array in the_post_thumbnail

 

 if( has_post_thumbnail() ) {
//Add in featured image & class
 the_post_thumbnail( 'featured-podcast', array( 'class' => 'alignnone' ) ); 
 }


This can be handy for coding out a custom loop.

1 Comment

  1. Sean Vandenberg on March 3, 2016 at 5:14 am

    Yes, yes, very useful. Thanks again, Neil. Always saving my day!

Leave a Comment





%d bloggers like this: