WordPress.org

Ready to get started?Download WordPress

Forums

Purpose of .sticky and .gallery-caption CSS Class? (15 posts)

  1. chaseman
    Member
    Posted 3 years ago #

    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?

  2. chaseman
    Member
    Posted 3 years ago #

    Anyone?

  3. esmi
    Forum Moderator
    Posted 3 years ago #

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

  4. chaseman
    Member
    Posted 3 years ago #

    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?

  5. Chip Bennett
    Theme Review Admin
    Posted 3 years ago #

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

  6. esmi
    Forum Moderator
    Posted 3 years ago #

    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.

  7. chaseman
    Member
    Posted 3 years ago #

    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.

  8. chaseman
    Member
    Posted 3 years ago #

    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?

  9. Chip Bennett
    Theme Review Admin
    Posted 3 years ago #

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

  10. chaseman
    Member
    Posted 3 years ago #

    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"

  11. chaseman
    Member
    Posted 3 years ago #

    This will work:

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

    Thanks

  12. Chip Bennett
    Theme Review Admin
    Posted 3 years ago #

    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?

  13. chaseman
    Member
    Posted 3 years ago #

    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.

  14. ANDY SCARLES
    Member
    Posted 2 years ago #

    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

  15. Chip Bennett
    Theme Review Admin
    Posted 2 years ago #

    @ANDY SCARLES

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

Topic Closed

This topic has been closed to new replies.

About this Topic