Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PHP

add javascript to functions.php

/****
  To get started, locate and open your functions.php file, 
  then copy and paste the following code snippet:
****/
function ti_custom_javascript() {
    ?>
        <script>
          // your javscript code goes here
        </script>
    <?php
}
add_action('wp_head', 'ti_custom_javascript');

/****
This code above will add JavaScript to your header. 
To apply it to a single post only, you can use the following:
****/
function ti_custom_javascript() {
  if (is_single ('3')) { 
    ?>
        <script type="text/javascript">
          // your javscript code goes here
        </script>
    <?php
  }
}
add_action('wp_head', 'ti_custom_javascript');
/****
Note that you’ll need to replace the 3 
in the above example with the post ID number 
to which you want to add the code. To locate 
that number, navigate to the post from your 
admin dashboard, and then click on Edit. In 
the browser bar’s URL, the ID number is the 
number next to “post=”:
Source by themeisle.com #
 
PREVIOUS NEXT
Tagged: #add #javascript
ADD COMMENT
Topic
Name
1+8 =