Do you want to add custom attributes in your the_post_thumbnail (WordPress featured image) such as SEO, Javascript or JQuery attribute?
Then you came to the right place.
Here:
We have posted the simple code snippet that will help you to easily set any attribute and give the value in your the_post_thumbnail function.
Just follow the below steps.
Add Custom Attribute to image by using the_post_thumbnail
Just copy the below code and paste it into your theme’s file where you inserted the post thumbnail image.
For eg: If you want to add some attribute in your single post’s page, then just put these code in your single.php file.
After that:
Just change the attribute, as what Attribute you want.
Code Snippets for Custom Attribute to the_post_thumbnail
Hope the above code helped you and it’s working as the way you want.
Let us know if you face any issues in the comment box.
Don’t forget to share this custom attribute to post_thumbnail_function.
Wow! Is it so simple, I want to do it.