Topic: Target specific category in CSS | WP Masonry Layout

Target specific category in CSS

Home Forums Pro Version Target specific category in CSS

This topic contains 4 replies, has 3 voices, and was last updated by  Masonry Guy 10 months, 3 weeks ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #11774 Reply

    Anita
    Participant

    Hi,

    I am trying to customize my blog posts based on the category. Specifically, I would like to assign a border of a different color to each category. How do I target the category ID in CSS? In the default wordpress blog template, every post had a category class so I would just do something like .category-job-posts, but I don’t see it in the masonry page.

    Thanks for your help!

    #11790 Reply

    Masonry Guy
    Keymaster

    Hi Anita,

    Currently we don’t have such feature. But it can be done with certain tweaks. You can add the category name as class from to the layout you are using and assign the css as per it. To make changes in layouts, please go to layouts and then copy it to wordpress theme. From there you will get new location. You can navigate to it and make changes in layout.php.

    Thanks

    #11836 Reply

    Anita

    Thank you! I got to the point of copying my layout (pinterest inspired) to wordpress theme. I didn’t manage to have the code to add the class to work though (I am a beginner). Any chance you could send it over? Thanks!

    #11849 Reply

    Anita

    OK, I got it. In case anyone else needs this, I added the following code to <div class=”wmle_item”>:

    <?php foreach( get_the_category() as $cat ) { echo $cat->slug . ‘ ‘; } ?>

    #11864 Reply

    Masonry Guy
    Keymaster

    Hi Anita,

    Ya, that how you need to use. Thank you so much for sharing it here.

    🙂

Viewing 5 posts - 1 through 5 (of 5 total)
Reply To: Target specific category in CSS
Your information: