Viewing 16 posts - 1 through 16 (of 16 total)
  • Author
    Posts
  • #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 Harris

    #889227

    Hey sharris05,

    Which code do you want to add inside of the body tag and for what reason?

    Best regards,
    Rikard

    #889306

    Hey Rikard,

    I have JSON-LD for schema to insert.

    Thanks,
    Susan

    #889505

    Hi,

    Thanks for the feedback, though I’m not familiar with that. Exactly what code do you need to go where?

    Best regards,
    Rikard

    #889551

    Hi 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,
    Susan

    #889562

    Hi 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,
    Victoria

    #889566

    Hi Victoria,
    Thank you for your help,
    Susan

    #889570

    Hi,
    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,
    Mike

    #889743

    Hi 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,
    Susan

    #889782

    Hi,
    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,
    Mike

    #890335

    Hi Mike,

    Thank you for your help. Much appreciated!
    Regards,
    Susan

    #890365

    Hi 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,
    Rikard

    #1112900

    Mike 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/&#8221;,
    (OTHER JSON TAGS IN HERE)
    ]
    }
    </script>
    </body>

    #1113103

    Hi laptophobo,

    It’s a script, so it’s wrapped in script tag which is correct.

    Best regards,
    Rikard

    #1113185

    Okay, thanks for the look-over. I didn’t think I had to wrap it in a “<?php>” tag, but wanted to check anyway.

    #1113342

    Hi laptophobo,

    Glad you got it working for you! :)

    If you need further assistance please let us know.

    Best regards,
    Victoria

Viewing 16 posts - 1 through 16 (of 16 total)
  • You must be logged in to reply to this topic.