WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Can you please let me know how to find out a galley's ID? and Can we use this ID in CSS styling? if not how we can stylize two different galleries in diffident style?(to be honest I am not sure this is possible or not but I hope!)

share|improve this question
The gallery CSS is automatically generated using both an ID and a unique class. Right click your page and select element. – Wyck Jan 30 '13 at 8:03

The [gallery] shortcode supports specifying the gallery's id by supplying the id parameter. More on this in the documentation.

However, using id might be contra productive if you wish to use two different styles of galleries across your site, in which case you would need to use the same style for a whole lot of #ids in your CSS - which you might not even know beforehand. Unfortunately there is not class attribute available. To accomodate this need you could remove the default gallery shortcode and add your own shortcode handler function replicating the functionality of gallery_shortcode while adding support for a class parameter or what you might need.

remove_shortcode('gallery', 'gallery_shortcode');
add_shortcode('gallery', 'my_gallery_shortcode');

function my_gallery_shortcode($attr) {

EDIT: Another, perhaps simpler, option to accomplish the same thing would be the create a wrapper shorttag for gallery:

add_shortcode('my_gallery', 'my_gallery_shortcode');

function my_gallery_shortcode($attr) {
    $attr = shortcode_atts(array('class' => 'gallery-wrapper'), $attr);
    $class = $attr['class'];

    return '<div class="' . $class . '">' . gallery_shortcode($attr) . '</div>';
share|improve this answer
A CSS3 Selector, like ^= could be handy, no? – brasofilo Jan 30 '13 at 8:02
Sure, that's a great solution. Turns out that selector has way more browser support than I thought. – Simon Jan 30 '13 at 8:19

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.