Support » Plugins » Hacks » remove class from the_post_thumbnail

Viewing 3 replies - 1 through 3 (of 3 total)
  • esmi


    Forum Moderator

    Why are you even trying to remove the classes from the post thumbnail?

    Very bad case of OCD.

    I do not use them and like to keep my code as tidy as a nuns buttocks.

    Any hint?

    “Very bad case of OCD.” Well at least you are honest. 🙂

    It doesn’t work because ‘the_post_thumbnail’ is not a valid filter. You need to use ‘post_thumbnail_html’ if you want to filter the output, like this:

    //remove class from the_post_thumbnail
    function the_post_thumbnail_remove_class($output) {
        $output = preg_replace('<code>class=&quot;(.*?)&quot;</code>', '', $output);
        return $output;
    add_filter('post_thumbnail_html', 'the_post_thumbnail_remove_class');

    I still don’t understand why you think adding a 5-line function (and a function that uses a regex, no less) in order to remove a class name makes your code any tidier. But, to each his own! 😉

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘remove class from the_post_thumbnail’ is closed to new replies.