Home › Forums › General Issues › ACF field for JSON code (using elementor widget)
Do anyone knows if it is possible to insert JSON-LD code (such as below) into an ACF field that is connected to a elementor widget (eg. a HTML elementor widget with the ACF field as input)? At the moment, when I insert JSON-LD code, the front-end removes the <script> tag somehow :O Even though i insert the code below into the ACF field.
<script type=”application/ld+json”>
{
“@context”: “https://schema.org”,
“@type”: “FAQPage”,
“mainEntity”: [
{
“@type”: “Question”,
“name”: “Hvad er kernemælk?”,
“acceptedAnswer”: {
“@type”: “Answer”,
“text”: “Kernemælk er en lavfedtig mælkevariant, der er blevet syrnet ved tilsætning af mælkesyrebakterier. Den har en let og syrlig smag og kan bruges i mange forskellige madlavning og bagning opskrifter.”
}
}
,
{
“@type”: “Question”,
“name”: “Hvad er forskellen på kernemælk og kærnemælk?”,
“acceptedAnswer”: {
“@type”: “Answer”,
“text”: “Kernemælk og kærnemælk er faktisk det samme produkt. De to navne bruges ofte om hinanden i Danmark.”
}
}
,
{
“@type”: “Question”,
“name”: “Hvad kan jeg bruge kernemælk til?”,
“acceptedAnswer”: {
“@type”: “Answer”,
“text”: “Kernemælk kan bruges som ingrediens i bagværk som brød og kager for at gøre dem mere luftige og saftige. Den kan også bruges til at lave marinader, dressinger og smoothies, eller bare drikkes rent som en forfriskende drik.”
}
}
]
}
</script>
Elementor strips code, as do most page builders.
Use an AFC textarea field with no formatting on the returned values and use the ACF Shortcode to insert it on the page.
Using the ACF textarea does not work. It still sanitizes by removing the script tag?
Did you use a shortcode to insert the field/content of did you use the Elementor dynamic content feature to select the field?
I did not use a shortcode, because i need to add dynamic JSON code. Shortcodes does not seem to make sense for dynamic code, right?
Elementor kses’s all content included that way and there is not way that I know of to turn that off. You cannot use the dynamic elemetor feature to add code that excludes anything cleaned out by kses.
You could have to bring this up with elementor.
Elementor says it is your guy’s responsibility since it’s a third party. You must have some kind of solution on this, right? Can’t i do anything? Don’t you have a ACF type that accepts all kinds of code?
No, there is no solution. The only integration with elementor comes from elementor. ACF has no built in integration for page builders.
Elementor is what is striping the script tags, not ACF. ACF will output whatever is in a text area without stripping tags as long as it is set to not format the content in the return value settings.
This is why you need to use a shortcode. If the content being output is a field on the current post then you can use [acf field="field_name"]
. Others have used this method because elementor does not appear to affect content returned by a shortcode.
https://www.advancedcustomfields.com/resources/shortcode/
That depends, do you trust the people that have access to edit that ACF field?
Editors can put malicious code into ACF fields.
As far as security goes, the only people that are allowed to edit sites I build are my company and the owners of the site and people they designate to make changes.
If you are giving edit access to people that may not be trustworthy then you should consider not allowing specific user roles to edit ACF fields that can be used for malicious intent. This can be done using an acf/prepere_field filter and removing the fields from the editor based on user role.
You must be logged in to reply to this topic.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.