badget

Biggest Sale! Special Offer!

Get 30% discount on all of our single themes with this coupon code: #30%SALE

Hurry up! *Limited time offer*

How to Run Javascript in the Custom Footer

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #23545
    Bill
    Participant

    I have logo-links to Angie’s List, the Chamber of Commerce and the Better Business Bureau that require JavaScript to run properly. Is there a way to make this work in the footer or a work around to make it look like a footer. I bought premium in order to be able to customize the footer, but without this capability, it doesn’t really solve my problem. Can someone help me?

    Thanks,

    Bill

    #23553

    Hi Bill,
    We recommended not to change the code because if you change the code then while updating to our new version all your customisation code will be lost. So better make child theme and first unhook the functions and the edit the code.

    http://codex.wordpress.org/Child_Themes
    You may try this below code.

    function attitude_javascripts() {
        wp_enqueue_script( 'the-script-handle', 
                           'path/to/file.js', 
                           array( 'jquery','other_script_that_we_depend_on' ), 
                           'scriptversion eg. 1.0', 
                           true);
    }
    add_action( 'wp_enqueue_scripts', 'attitude_javascripts' );

    If you are unable to add then you may hire a developer to fix it.

    Thank you!

    #23568
    Bill
    Participant

    I already use a child theme, I set that up right away. I added this function to the functions.php file and it isn’t working. Is there something that I may be missing?

    Thanks, Bill

    #23633

    Hi Bill,

    Add this code inside child theme of attitude- pro
    Ceate a style.css file and add this below code.,

    /*
    Theme Name: Attitude Child Theme
    Author: Self-Help Theme Horse
    Template: Attitude Pro Child
    */
    
    /*@import url("../attitude/style.css"); */

    After doing it create one functions.php file inside child theme.

    function attitude_javascripts() {
        wp_enqueue_script( 'backtotop', ATTITUDE_JS_URL. '/backtotop.js', array( 'jquery' ) ); // this is an example
    }
    add_action( 'wp_enqueue_scripts', 'attitude_javascripts' );
    

    If you are still unable the you need to hire a developer to fix it.

    Thank you!

    #23655
    Bill
    Participant

    Thank you, but it didn’t work. I even uncommented out the @import URL… in the CSS file. I already had both style.css and functions.php files in the child theme. Will you consider allowing Javascript to run natively in the footer in the next update?

    Thanks, Bill

    #23658

    Hi Bill,

    We are sorry for this. You may simply add your javascript inside footer.php if you want but while updating each and everytime you need to do the same things.

    Thank you!

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.