WordPress.org

Support

Support » How-To and Troubleshooting » [Resolved] Remove Post Thumbnail classes

[Resolved] Remove Post Thumbnail classes

Viewing 12 replies - 1 through 12 (of 12 total)
  • wpismypuppet

    @wordpressismypuppet

    What’s the error?

    Warning: preg_replace() [function.preg-replace]: Unknown modifier ‘c’ in C:\Users\Chris\Desktop\wamp\www\wordpress\wp-content\themes\murtaugh-HTML5-Reset-Wordpress-Theme-8aa6329\functions.php on line 164

    Line 164: $output = preg_replace('<code>class=&quot;(.*?)&quot;</code>', '', $output);

    wpismypuppet

    @wordpressismypuppet

    It’s the correct code, but an incorrect preg_replace. Use this… I tested and it works:

    //remove class from the_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');

    Really appreciate that.

    wpismypuppet

    @wordpressismypuppet

    You are welcome…

    For some reason it leaves off the trailing ‘/>’ of the img tag.

    Edit: My fault.

    wpismypuppet

    @wordpressismypuppet

    Mine is still there… make sure you check your source code, and not just through Firebug or something… my Firebug leaves it off, but my source code shows it.

    Yeah, it’s all good. I didn’t see it at first but it’s there.

    Hello, I have the same issue except that I seem to know less about codes than both of you. I’m working with Gridportfolio theme. Could you tell me where to put the code posted above and other details i should know for the ‘post-thumbnails’ to be disabled?
    Thanks!

    The code above goes into the functions.php file.

    Olá, tudo bem?
    Desculpa o encomodo, mas é que estou a procura de alguém pra me quebrar um galho.
    Seguinte, tenho esse blog http://www.valmirlima.com.br que estou programando, porém ele é meio diferente dos outros, porque mesmo se eu não inserir imagem no post, aparece esse thumbnail na página principal. Como a maioria dos posts no blog não tem imagem, fica estranho né. Daí quero saber se voces podem me dar essa força, porque já procurei nos códigos e nada.
    Eu quero que apareça imagem na home apenas quando eu colocar imagem destacada, quando eu não colocar, é pra aparecer só o título e uma prévia do texto mesmo, como é na maioria dos blogs.
    Serei muito grato!

    Michael

    @alchymyth

    Forum Moderator

    @rabeloalexandre

    please post in English.

    and start a new topic.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘[Resolved] Remove Post Thumbnail classes’ is closed to new replies.
Skip to toolbar