How to Add a Class Name to WordPress Post Thumbnail

WordPress allows you to display post thumbnail or featured image of a post by using the_post_thumbnail() function. But, sometimes adding a post thumbnail is not enough. You may want to add your own custom CSS class to the image tag generated by this function. You can easily do that by passing an array of parameters to the function.

Quick Tip : How to convert a negative number to a positive number

<?php the_post_thumbnail('full', array('class' => 'class-name')); ?>

For more information : https://codex.wordpress.org/Function_Reference/the_post_thumbnail

0 Comments

Leave a Comment.