-
AuthorPosts
-
December 15, 2017 at 3:09 am #889180
I want to insert JSON-LD code in the <body> of my website. I’ve done it in other themes
but I can’t seem to figure it out in Enfold.
Thanks for your help,
Susan HarrisDecember 15, 2017 at 9:08 am #889227Hey sharris05,
Which code do you want to add inside of the body tag and for what reason?
Best regards,
RikardDecember 15, 2017 at 2:34 pm #889306Hey Rikard,
I have JSON-LD for schema to insert.
Thanks,
SusanDecember 16, 2017 at 9:55 am #889505Hi,
Thanks for the feedback, though I’m not familiar with that. Exactly what code do you need to go where?
Best regards,
RikardDecember 16, 2017 at 4:21 pm #889551Hi Rikard,
If you are not familiar with schema, this link will be helpful: https://jsonld.com/why-json-ld/
It goes before the closing body tag.
Take care,
SusanDecember 16, 2017 at 4:41 pm #889562Hi Susan,
You can try adding the code with this snippet to your functions.php
function av_add_code() { ?> <script> your JavaScript here </script> <?php } add_action('wp_footer', 'av_add_code');
If you need further assistance please let us know.
Best regards,
VictoriaDecember 16, 2017 at 4:50 pm #889566Hi Victoria,
Thank you for your help,
SusanDecember 16, 2017 at 5:02 pm #889570Hi,
Thanks for the link, from what I read:It is generally safe to insert JSON-LD code within the
of your website, as such this is what we recommend. JSON-LD can also be inserted in the of a website, or anywhere else for that matter.with this in mind, to place the code in the head, try inserting in: Enfold Theme Options > Google Services > Google Analytics Tracking Code text box. This box can be used for any code to be placed in the head.
If you want to place the code just before the closing body tag, then edit footer.php and look at the bottom, html can be used at that point of the file. We recommend creating a copy of the footer.php in your child theme with your changes so it will be preserved though theme updates.Best regards,
MikeDecember 17, 2017 at 4:55 am #889743Hi Mike,
That’s very helpful info, thank you.
If I don’t have the child theme installed will I lose the changes if I put the code in the Google Analytics Tracking Code
text box?
Thanks again,
SusanDecember 17, 2017 at 2:47 pm #889782Hi,
You will not lose those changes when updating, they are saved in the database with the theme settings. If you decide to use a child theme in the future, you can use the “export theme settings” from the parent theme then “import theme settings” to the child theme to save all of your settings.Best regards,
MikeDecember 19, 2017 at 5:32 am #890335Hi Mike,
Thank you for your help. Much appreciated!
Regards,
SusanDecember 19, 2017 at 7:58 am #890365Hi Susan,
Glad we could help. Please let us know if you should need any further help on the topic or if we can close it.
Best regards,
RikardJune 24, 2019 at 12:11 pm #1112900Mike suggested placing the json script in the footer.php file, just before the closing body tag. Does it need to be wrapped in php code, or do I have it correct like this?:
<?php
wp_footer();
?><script type=”application/ld+json”>
{
“@context”: “http://schema.org/”,
(OTHER JSON TAGS IN HERE)
]
}
</script>
</body>June 25, 2019 at 5:08 am #1113103Hi laptophobo,
It’s a script, so it’s wrapped in script tag which is correct.
Best regards,
RikardJune 25, 2019 at 10:09 am #1113185Okay, thanks for the look-over. I didn’t think I had to wrap it in a “<?php>” tag, but wanted to check anyway.
June 25, 2019 at 6:56 pm #1113342Hi laptophobo,
Glad you got it working for you! :)
If you need further assistance please let us know.
Best regards,
Victoria -
AuthorPosts
- You must be logged in to reply to this topic.