skip to Main Content

I am using the divi theme and had a simple line of javascript running in footer.php:

<script>
    console.log("inside of footer.php");
</script>

Then, i used Divi Theme Builder to make a custom footer and found that footer.php was no longer running. I need to add javascript back into the footer but can’t figure out what file to enter it in. How do I place javascript into the footer?

2

Answers


  1. It is not recommended at all to edit the footer.php template in an external theme.

    The way we use this is.

    1. Go to your_page/wp-content/themes/active_theme_name

    2. Create a custom.js

    3. Then in the functions.php add this line:

    wp_enqueue_script( 'customjs', get_template_directory_uri() . '/custom.js', array ( 'jquery' ), 1.1, true);

    Read, now you can write your console.log("inside of footer.php"); in a custom.js file.

    Login or Signup to reply.
  2. Here’s a brief tutorial by the creators of Divi covering how to include javascript on your Divi website.

    https://www.elegantthemes.com/blog/divi-resources/best-practices-for-using-external-javascript-snippets-with-divi

    Assuming you want to include your code in the footer for UX/SEO reasons, then the best route is probably to go to Divi > Theme Options > Integration and paste your code in the Add code to the <body> section.

    This will insert your code immediately before the closing </body> tag on all your pages.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search