Skip to main content
CSS-Tricks
  • Articles
  • Videos
  • Almanac
  • Newsletter
  • Guides
  • DigitalOcean
  • DO Community
Search
Code Snippets → WordPress → Remove Gallery Inline Styling

Remove Gallery Inline Styling

Avatar of Chris Coyier
Chris Coyier on Jan 25, 2012
add_filter( 'use_default_gallery_style', '__return_false' );
Psst! Create a DigitalOcean account and get $200 in free credit for cloud-based hosting and services.

Comments

  1. Vitor Melo
    Permalink to comment# May 23, 2013

    Thanks

    Reply
  2. Bogdan
    Permalink to comment# July 10, 2013

    Simple and usefull … thanks!

    Reply
  3. Tyler
    Permalink to comment# September 29, 2013

    Doesn’t work in WordPress 3.6, inline styles are still there.

    Reply
  4. Metacrawl
    Permalink to comment# April 30, 2014

    Oh! Works great in 3.9

    Reply
  5. BuffaloChuck
    Permalink to comment# August 2, 2014

    Added this to my theme’s functions.php. Seems simple enough, but doesn’t work for me. (I’m using WordPress 3.9.1 with a child theme based on Twenty Eleven 1.2.)

    Reply
    • BuffaloChuck
      Permalink to comment# August 2, 2014

      Anyone else have problems?

  6. Sarah DaSilva
    Permalink to comment# October 17, 2014

    Not working in WP 4.1-alpha :/

    Reply
  7. Samantha
    Permalink to comment# June 5, 2015

    Dude, you are the Splinter to my Ninja Turtle.
    I created a function just to get rid of the WP injected inline style, and then spent all day trying to make that function work without breaking a bunch of other stuff…then I found this. This super simple, completely effective filter. I’m kicking myself for the time I wasted today. I know better: always check on css-tricks first.

    Thank you for being awesome!

    Reply
  8. rtpHarry
    Permalink to comment# August 11, 2015

    If you’re having problems then check this out for a modern tip to control the styles (although for me the original method in this article did work, it just removed too many of the styles)

    https://make.wordpress.org/core/2014/04/15/html5-galleries-captions-in-wordpress-3-9/

    Reply
  9. Valentin Born
    Permalink to comment# July 14, 2016

    Just for some pedantry—we are talking about “internal” styles, not “inline”, right?
    And the “modern version” works great:

    add_theme_support('html5', array('gallery', 'caption'));
    
    Reply

Leave a Reply Cancel reply

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

CSS-Tricks is powered by DigitalOcean.

Keep up to date on web dev

with our hand-crafted newsletter

DigitalOcean
  • DigitalOcean
  • DigitalOcean Community
  • About DigitalOcean
  • Legal
  • Free Credit Offer
CSS-Tricks
  • Email
  • Guest Writing
  • Book
  • Advertising
Follow
  • Mastodon
  • Twitter
  • Instagram
  • YouTube
  • CodePen
  • iTunes
  • RSS
Back to Top