Hello,
I have a counter on my homepage, developed by a friend and each time I update the theme, I have to do this :
– add comerso.js file in Enfold / js
– add this code at the bottom of footer.php
<div id="fb-root"></div>
<script src="/wp-content/themes/enfold/js/comerso.js" type="text/javascript"></script>
</body>
Today, I’ve created a child theme.
Do I have to create a js folder to put my comerso.js file?
And to change footer.php, how can I add my code at the bottom, but getting the update of the rest of the file?
Tx for your help! I give you all the credentials below.
Marine
Hey newki75,
Please add your comerso.js file in a js folder in your child theme, then enqueue it by adding this script to your child theme functions.php:
// Register and enqueue scripts
function my_custom_scripts() {
wp_enqueue_script(
'comerso',
get_stylesheet_directory_uri() . '/js/comerso.js',
array( 'jquery' )
);
}
add_action( 'wp_enqueue_scripts', 'my_custom_scripts' );
it will then be loaded with your site in the footer.
You can read more about it here: How to add Custom JS or PHP Script
Best regards,
Mike
Tx Mike. So I can remove this code from my footer.php file?
<div id="fb-root"></div>
<script src="/wp-content/themes/enfold/js/comerso.js" type="text/javascript"></script>
</body>
Tx for your help!
Hi,
Yes you can remove it as it will be loaded with the new function.
Best regards,
Mike
Tx Mike, it works perfectly :-)
My updates will be easier / quicker now.
Have a nice day, you can close the issue :-)
(Enfold is definitely my favorite theme, better than Avada ! with a great support)
Hi,
Glad we were able to help, we will close this now. Thank you for using Enfold.
For your information, you can take a look at Enfold documentation here
For any other questions or issues, feel free to start new threads under Enfold sub forum and we will gladly try to help you :)
Best regards,
Mike