Portfolio
Portfolio
ADS

How to Add Custom Javascript into Your WordPress Site

In some situations, you may need to add custom Javascript to your site. Normally, this would involve modifying your theme files.

However, there is a less intrusive alternative. “Header and Footer Scripts” is a plugin to add custom JavaScript to WordPress without modifying your theme.

Upload a custom Javascript file

  1. Save your custom JavaScript code into a file with the .js format
  2. Upload it into your site to this folder: wp-content/themes/your-theme/js/
  3. Go to Settings Header and Footer Scripts
  4. Insert script in header (load inside head tag) or footer (load before closing body tag)
  5. Click Save settings button when you’re done

Use the location that match better your needs using this syntax as example:

<script src=”http://www.yoursite.any/wp-content/themes/your-theme/js/file.js”></script>

Load custom JavaScript without a file

  1. Go to Settings Header and Footer Scripts
  2. Add your code script directly in header (load inside head tag) or footer (load before closing body tag)
  3. Click Save settings button when you’re done