Home / functions.php / Remove the_post_thumbnail class
  • How to Remove the_post_thumbnail class

    add-featured-image-rss-feed

    Have you ever been using the_post_thumbnail( 'thumbnail' ); but wanted to remove the class that is automatically added. Add the following snippet to the functions.php of your wordpress theme to automatically remove any class. Simple but effective,

    ( click code to copy )

    wordpress snippet : PHP

    <>
    function wps_post_thumbnail_remove_class($output) {
            $output = preg_replace('/class=".*?"/', '', $output);
            return $output;
    }
    add_filter('post_thumbnail_html', 'wps_post_thumbnail_remove_class');
    

    ( WordPress codex functions, hooks, in this snippet. )

    add_filter, wp,