Remove class from Post Thumbnails

When you use this code, it will remove all classes associated to your <img>. This might be especially helpful, when you’re switching from Blogger to WordPress.

To use this code, add it to your Theme’s functions.php, or by a Code Snippet Plugin.

// Remove class from post thumbnail
function the_post_thumbnail_remove_class($output) {
    $output = preg_replace('/class=".*?"/', '', $output);
    return $output;
}
add_filter('post_thumbnail_html', 'the_post_thumbnail_remove_class');

Posted

in

by

Tags:

Comments

Leave a Reply

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