Hello team,
I am trying to add HTML and CSS to each metafield of my products (manually) by using tags and CSS styles like this example:
Hallo
I have even tried to convert the HTML and CSS to JSON so I can use it on one of the metfields like this {
“p”: {
“@style”: “color: red;”,
“#text”: “Hallo”
}
}
But to no avail, it doesn’t seem to appear on the custom liquid when I add one to my product page as shown in the screenshot bellow.
Please let me know if there’s a solution to this, and if not then what will the alternative be?
With all due respect,
Jeremiah.
1 Like
Hi @Jeremiah101
Why you need to add the HTML,
In this case you can add the content, color, then write some liquid code make the style as you want without HTML metafield
That wouldn’t be possible, since I need different texts with different colors in different products, but I only want to use one custom liquid and not one for each product.
I think you can build that with metafield,
You can create 2 field, 1 is for text, other for color,
or you only need to add only one metafield contain string ex: “This is your text: red”
Then write some liquid code to make the text show with the color you added.
I am afraid this isn’t helpful as I will need to change more than just the color, I mean I will have to change the background colors as well, the fonts and a whole bunch of things, that’s why I asked if it would be possible to use CSS and HTML in metafields?
Thank you!
I think use the metafield can resolve your problem.
Could you give me an example of a metafield where the background color (background-color) is being changed sir?
With all due respect!
To display metafield of html you can follow this tutorial: