Remove Gallery Inline Styling

add_filter( 'use_default_gallery_style', '__return_false' );

Comments

  1. User Avatar
    Vitor Melo

    Thanks

  2. User Avatar
    Bogdan
    Permalink to comment#

    Simple and usefull … thanks!

  3. User Avatar
    Tyler
    Permalink to comment#

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

  4. User Avatar
    Metacrawl
    Permalink to comment#

    Oh! Works great in 3.9

  5. User Avatar
    BuffaloChuck
    Permalink to comment#

    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.)

  6. User Avatar
    Sarah DaSilva
    Permalink to comment#

    Not working in WP 4.1-alpha :/

  7. User Avatar
    Samantha

    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!

  8. User Avatar
    rtpHarry
    Permalink to comment#

    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/

  9. User Avatar
    Valentin Born
    Permalink to comment#

    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'));
    

Submit a Comment

Posting Code

You may write comments in Markdown. This makes code easy to post, as you can write inline code like `<div>this</div>` or multiline blocks of code in triple backtick fences (```) with double new lines before and after.

Code of Conduct

Absolutely anyone is welcome to submit a comment here. But not all comments will be posted. Think of it like writing a letter to the editor. All submitted comments will be read, but not all published. Published comments will be on-topic, helpful, and further the discussion or debate.

Want to tell us something privately?

Feel free to use our contact form. That's a great place to let us know about typos or anything off-topic.

icon-anchoricon-closeicon-emailicon-linkicon-logo-staricon-menuicon-nav-guideicon-searchicon-staricon-tag