Different background color for each post in archive post

hi there,

i made an acf color picker field and wanna have a different background color for each post in the post archive page. i made all background colors transparent except the background for the post element.
i then added a background image upper layer color and did that element css:

  $el .x-bg .x-bg-layer-upper-color {
      background-color: {{dc:acf:field field="back_color"}} !important;
  }

but now, the color for from the latest post is the color for all posts. how can i archive a seperate color for each post on the post archive page?

thanks in advance
cheers

Hello @deranaloge,

Thanks for writing in! Regretfully you cannot use shortcodes or any PHP code in the custom element CSS. You will need custom PHP codes in your child theme’s functions.php file to make it happen. Be advised that this is beyond the scope of our support. You may need to hire a 3rd party developer to accomplish this if you are not familiar with PHP and coding.

Best Regards.

hm i dont get it sorry,
i have setup a different color for each single post. but in the archive builder the color for the latest post will be used for all posts on the archive page. all is dynamicly, why the color not?

Hi @deranaloge,

While setting the Color or any style in the Archive layout under the Layout Builder is implementing into all the posts. And that is why the color can’t be implemented for each post.

Thanks for understanding

can you add a feature request?
since the background image is allready dynamic (i can make different images for each post) can you add a request to make the background color also dynamic? should be easy to implement and this would be really great.
so i can use background color in the post, setup the background color dc to it and finsihed.

one more question: can i make classes for it? does that work?

cheers

Hi @deranaloge,

It is not possible logically, as the loop can’t calculate the no. of posts and the color input from the users. Still, I will pass this as a Feature request to our development team, so it might be taken into account in the future.
You can add the class into the parent posts element and use the Numeric Selection option of CSS to add the style, please find the article below on how to do that.

Thanks for understanding

hi tristup,

i will try the css logic.
but why shouldn’t that work with the color? it also works with the text, photos, etc., i only need to color the background with the color i define in the post. doesn’t sound too difficult.

Hi @deranaloge,

I have already made a Feature Request on this to our team, so it might be taken into account in the future.

Thanks

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.