[Resolved] Easiest way to add Javascript?

Home Forums Support Easiest way to add Javascript?

  • This topic has 3 replies, 2 voices, and was last updated 2 months ago by David.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1370479
    Daniel

    I’ve been asked by a client to add a map which uses Javascript – what is the easiest way for me to add this to a page?

    It looks like the below (with unique ID’s removed).

    `<div id = ‘show-poi-widget-here’> </ div>
    <script type = ‘text / javascript’
    src = ‘ https://api.easygis.eu/ js / latest.js ‘> </script>
    <script type = ‘text / javascript’>
    easygis.loadModule ({
    key: ‘ ‘,
    module: easygis.Module.POIWIDGET,
    target: ‘show-poi-widget-here’,
    uuid: ”
    });
    </script>`

    #1370512
    David
    Staff
    Customer Support

    Hi there,

    you could just add the HTML and JS straight into a HTML Block. As long as the Script comes after the HTML it will work.

    Or you can use a Hook Element to add the <script> to the WP_footer

    https://docs.generatepress.com/article/hooks-element-overview/

    Then add the <div> within your content or another Hook.

    #1370572
    Daniel

    Thanks David – I tried adding it as a custom HTML block previously but for whatever reason it didn’t work and assumed I was doing something wrong.

    This time… it did. So, case closed, thank you.

    #1370603
    David
    Staff
    Customer Support

    Glad to hear that 🙂

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