I need to add a script in the site footer. I'm just referencing the footer.php:
<script src="wp-content/file/script.js"></ script>
At Home functions normally, but when access a page child he does not find because search the directory:
site/page-child/wp-content/file/script.js.
I saw that I have to use:
wp_enqueue_script ()
But where should I put this code?
Thank's
You just need to add a "/" before your url in order to start it from root like :
<script src="/wp-content/file/script.js"></ script>
Indeed at home page it looks for yoursite.com/wp-content but on other pages it searches yoursite.com/current-page/wp-content and obviously it results in 404.
Adding / make it always look for yoursite.com/wp-content
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With