• I’m looking for help with a Javascript question. I’m trying to insert Javascript code onto a wordpress post.
    The code that needs to run is:
    <SCRIPT language='JavaScript1.1' SRC="https://example.com/example.example;dc_trk_aid=306750509;dc_trk_cid=71993047;ord=[timestamp];dc_lat=;dc_rdid=;tag_for_child_directed_treatment=?"></SCRIPT>

    From wordpress I got that to include Javascript inside a post, you need to combine the call to the script file with the call to the JavaScript itself. They provide this sample code:

    <script type="text/javascript" src="/scripts/updatepage.js"></script>
    <script type="text/javascript">
    <!--
    updatepage();
    //--></script>

    What I need to know is how to integrate the two.

Viewing 1 replies (of 1 total)
  • Please check to see if it works when just putting the above code in text editor.

    If not, check the correct path to updatepage.js.
    If the path is correct, you can use shortcode to add javascript even in visual editor, like [updatepate].

    Add this code in your functions.php.

    function print_updatepage_js() {
    $str =  '<script type="text/javascript" src="/scripts/updatepage.js"></script><script type="text/javascript"> updatepage(); </script>';
    return $str;
    }
    add_shortcode('updatepage', 'print_updatepage_js');

Viewing 1 replies (of 1 total)
  • The topic ‘Implementing Javascript in a post’ is closed to new replies.