Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add a script in wordpress theme footer dynamically

Tags:

php

wordpress

I wish to create a wordpress plugin to add below script in all pages. So I need to add that script in theme footer. How can I add it in footer.php using plugin?

eg script =

script type="text/javascript" src="sample.js">

also I wish to add it in before body closing tag..

Thank you..

like image 330
Vinu Sebastian Avatar asked Mar 28 '26 22:03

Vinu Sebastian


1 Answers

Use wp_enqueue_script to load the script in your themes functions.php file. Else, directly embed the script in your themes footer.php file.


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!