Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #990826

    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

    #990943

    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

    #990944

    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!

    #990958

    Hi,
    Yes you can remove it as it will be loaded with the new function.

    Best regards,
    Mike

    #991032

    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)

    #991101

    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

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Add js file and change footer.php in my child theme’ is closed to new replies.