Adding Class to WordPress Post Thumbnail

If the desired output of the default WordPress post thumbnail is not enough you can easily adjust the PHP to output your appropriate class.


<?php 
    the_post_thumbnail('post-thumbnail', 
      array( 'class' => "YOUR CLASS")); 
?>

More information can be found on the codex.

Want to become a better web developer?

Join over 25,000 other developer & designers who get awesome links to the best news and articles each week delivered directly to their inbox.


This entry was posted in Uncategorized and tagged .

1 Comment

  1. Please replace “Adding” by “Replacing” as this code REPLACES any other class by your own

This post currently has one response. What do you think?

You can use basic HTML when posting code, please turn all < characters into &lt; or > into &gt;
If the code is multi-line, use <pre><code></code></pre>

Leave a Reply

Your email address will not be published. Required fields are marked *