2

In Homepage trying to give color .feed-view .post-wrapper .snippet-thumbnail-container based on label. For example for label "Italiano" background-color:red and for label "English" background-color:blue,

<b:if cond='data:view.isHomepage'><style>.feed-view .post-wrapper .snippet-thumbnail-container{background-color:red!important}</style></b:if>

with this code all thumbnails get red in Homepage but when i add label condition ...

<b:if cond='data:view.isHomepage and data:post.labels any (l =&gt; l.name == &quot;Italiano&quot;)'><style>.feed-view .post-wrapper .snippet-thumbnail-container { background-color: red !important}</style></b:if>

with this code no color at all. My mistake is in condition post.labels but i can't find exactly what is the the mistake.

At the end only my Home Page should look like this: enter image description here

John Grischam
  • 224
  • 1
  • 19

1 Answers1

1

Search the theme for the below code (it may appear more than once, you can update them all, or keep testing until find the one you need to update):

<b:includable id='postWrapperClasses'>
  <b:class cond='data:post.featuredImage' name='image'/>
  <b:class cond='not data:post.featuredImage' name='no-image'/>
  <b:class cond='data:post.labels and not data:post.labels.empty' name='has-labels'/>
</b:includable>

And add this line to it, this will set a custom class if the post contains a label you choose.

<b:class cond='data:post.labels any l => l.name == "Italiano"' name='SOME-CLASS'/>

Then you can customize it using css

.SOME-CLASS .snippet-thumbnail-container {
    background: red !important;
}
Bouh
  • 1,303
  • 2
  • 10
  • 24
  • Maybe my post is not clear. I already explained that i tried loop with same results. Maybe it will be easier to check the website. Is Kritere.com and since they don't use images in their posts i'm trying to give a color IN HOMEPAGE to each .post-outer (each post container in feed) based on label. Please check also image added to post to make it more clear. – John Grischam Oct 13 '21 at 13:20
  • 1
    It works. Thank you – John Grischam Oct 13 '21 at 14:39