WordPress.org

Support

Support » Themes and Templates » Purpose of .sticky and .gallery-caption CSS Class?

Purpose of .sticky and .gallery-caption CSS Class?

  • I just checked my WordPress theme with WP Theme Check and it said that the CSS classes .sticky and .gallery-caption are REQUIRED in the theme style CSS file.

    I’m wondering what is the purpose of these two classes, what is achieved when I add them to my CSS file? Because the theme works great and without any problems without them as well.

    What should I look out for when adding these styles and applying styles to them – and where can I see the effects of the styles?

Viewing 14 replies - 1 through 14 (of 14 total)
  • Anyone?

    esmi
    Forum Moderator

    @esmi

    .sticky: styles sticky posts
    .gallery-caption: styles caption in the native WordPress Gallery.

    If you are coding a theme to WP standards, then it is simply required that you style both sticky posts and gallery captions.

    Makes sense, thanks for the response, it’s weird since ever I’ve been coding a WordPress theme (2 month now), I’ve never come across a sticky post or a native WordPress gallery, the only gallery I know is the one when I upload images in the admin panel – is that the one you mean, or is there a different one as well?

    Chip Bennett
    Theme Review Admin

    @chipbennett

    .sticky: styles sticky posts
    .gallery-caption: styles caption in the native WordPress Gallery.

    If you are coding a theme to WP standards, then it is simply required that you style both sticky posts and gallery captions.

    There is some debate over this, but right now, it is at least required that the classes be added to style.css, even if left empty. (The intent is to ensure that the developer has considered applying styles for sticky posts and for gallery captions, even if the design intent of the Theme precludes any particular styling.)

    it’s weird since ever I’ve been coding a WordPress theme (2 month now), I’ve never come across a sticky post or a native WordPress gallery…

    Do you use the Theme Unit Test data for your development? If not; you should be.

    the only gallery I know is the one when I upload images in the admin panel – is that the one you mean, or is there a different one as well?

    No, it is the gallery added inside a Post, via the [gallery] shortcode.

    esmi
    Forum Moderator

    @esmi

    No – that’s the one I mean. Try adding a caption to one of your gallery images and you’ll see the class in the source code.

    The test data from the Theme Unit Test provides a good foundation for developing & testing themes.

    Thanks for the great resource, yes I’m currently in the testing phase, so far I’ve used the plugin WP Theme Check to get rid of most of the notices and errors.

    I’ve just tried the sticky function, and it works as expected here, the only issue I have is the .sticky class does not get inserted in the source code at all, which means that when I style it in the css file the sticky post does get affected. Any ideas why?

    EDIT:

    Ok I figured out I need to add post_class(), problem is that I already have assigned two classes to that ul element, any ideas how I can combine them?

    Chip Bennett
    Theme Review Admin

    @chipbennett

    Have you added the <?php post_class(); ?> template tag where appropriate?

    wow you’re fast, I just edited my post. I’ve added post_class(), but as said I’ve already assigned a class for my own styles to that element, and the following will not work obviously:

    class=”my-style” class=”sticky-style”

    Any ideas how to combine them?

    To:

    class=”my-style sticky”

    This will work:

    <?php post_class('title_post group'); ?>

    Thanks

    Chip Bennett
    Theme Review Admin

    @chipbennett

    I’ve added post_class(), but as said I’ve already assigned a class for my own styles to that element, and the following will not work obviously:

    class="my-style" class="sticky-style"

    Any ideas how to combine them?

    The Codex is your friend. 🙂

    You can pass one or more classes, as a string, to the post_class() tag (as you demonstrate above).

    Though, I have to wonder: why do you need such arbitrary classes? Are not the core-defined classes sufficient for each semantic case?

    Though, I have to wonder: why do you need such arbitrary classes? Are not the core-defined classes sufficient for each semantic case?

    This is my first theme and I started with an empty template which I got from a video workshop, which did not include the proper post_class() functions in the tags, so I assigned my own.

    When I started I did not know about a CSS grid system as well, thus the over-use of clearfix.

    On my second project I’m going to create my own framework with the proper functions and a CSS grid system.

    ANDY SCARLES
    Member

    @andy-scarles

    Hi,

    I am trying to use the native gallery with the lightbox plugin, the plugin itself works fine, but the thumbnails sit to the left of the page.

    I have tried to change the CSS to make the thumbnails sit in columns of 4 but nothing seems to work..? Could someone point me in the right direction or tell me where I’m going wrong?

    http://dev.lucy-bell.com/2011/10/brian-duffy-2/

    Thanks

    Chip Bennett
    Theme Review Admin

    @chipbennett

    @andy SCARLES

    You need to start your own thread. Your issue is etirely unrelated.

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘Purpose of .sticky and .gallery-caption CSS Class?’ is closed to new replies.