Add custom css class to WordPress Gallery

I would like to add a custom css class to the native WordPress gallery. For example, this one outputs the following HTML:

<div id="gallery-2" class="gallery galleryid-1715 gallery-columns-4 gallery-size-thumbnail">

I’d like to just add in a custom class of iwmp.

Read More

What’s the best way of doing this? I was hoping for a non JS solution. Thanks

EDIT: Answered my question below.

Related posts

Leave a Reply

2 comments

  1. You should just be able to put your custom class in the list of classes and then, in your css file, describe the properties associated with that class.

    For example:

    Your html would be

    <div id="gallery-2" class="iwmp gallery galleryid-1715 gallery-columns-4 gallery-size-thumbnail">
    

    And then let’s say you wanted everything in class iwmp to have a red background color and have center alignment you would add the following to your css file:

    CSS addition:

    .iwmp {
        background: #ff0000;
        text-align: center;
    }