Do you want to add a Class to the_post_thumbnail
(Featured Image) in WordPress with just by simple code?
Then you came to the right place.
Here:
We have written custom function that will help you to easily add Class to the your Post featured image.
Just follow below steps.
Add Class to the_post_thumbnail
First, copy and paste the below embedded code into your WordPress theme’s functions.php file.
Code for Add Custom Class to Featured Image
After that:
Change the Class value to whatever class you want to give.
For Example: I want to add a class which named should be ‘product-img’, So I would change the class name from responsive-img
to product-img
That’s it.
Hope you understand this guide and the code is smoothly working.
Read also: Add Custom Attribute to Featured Image
If you face any error or have some questions, you can comment below.
Also, Don’t forget to share this Add a Class to “the_post_thumnbail” WordPress function guide.