Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
QUESTION How to Include .js File on All Pages?
#1
How to include an external script file on all pages on the site, that won't get broken when i update get-simple or update the theme?

Where to put this?

Code:
<script src="myscripts.js"></script>

Is there an add-on that would help

thx
Reply
#2
No need for add-on
Just use php include in the <head> section
or just before the </body> tag
Reply
#3
(2022-11-20, 20:19:23)Felix Wrote: No need for add-on
Just use php include in the <head> section
or just before the </body> tag

In which file?
Reply
#4
(2022-11-21, 01:20:19)johnywhy Wrote:
(2022-11-20, 20:19:23)Felix Wrote: No need for add-on
Just use php include in the <head> section
or just before the </body> tag

In which file?

Browse to your theme that you would like to update.
For example "\theme\Innovation\"
In this example, we will add it to the file "footer.inc.php"

Change lines 24-27 from:
Code:
</footer>

</body>
</html>

to:

Code:
</footer>
<script src="<?php get_theme_url(); ?>/assets/js/myscripts.js"></script>
</body>
</html>

And make sure you have saved your new "myscripts.js" file info folder "\theme\Innovation\assets\js"

You can adapt this method to whichever theme you are using.


GS Community Edition with php8.x compatibility, new features and much more!  Support Me


Reply




Users browsing this thread: 1 Guest(s)