• I am new to WordPress development. I have successfuly added a child theme to the customizr theme. I know this because the css in my style.css work fine. However I need to add some custom javascript files and I have not yet been successful. Here is the code:

    function theme_javascript(){

    if(is_page('retreats')){
    // Deregister scripts
    wp_deregister_script('ecwidapi');
    wp_deregister_script('mytempo');

    // Register jSon template
    wp_register_script('mytempo',get_template_directory_uri().'/js/tempo.js');

    // Register ECWID api
    wp_register_script('ecwidapi',get_template_directory_uri().'/js/ecwidapi.js',array('jquery'));

    wp_enqueue_script('mytempo');
    wp_enqueue_script('ecwidapi');
    }
    }

    add_action(‘wp_enqueue_scripts’,’theme_javascript’);

    I want to remove this from the customizr functions.php file (where I have it now) and put it properly somewhere in a file in the child theme. Copying the functions.php file to the child directory and adding this code hasn’t worked.

    Thank you advance for your instruction.

    John

Viewing 2 replies - 1 through 2 (of 2 total)
  • functions.php in a Child Theme is different to other .php files. If you have copied the core functions.php in its entirety then that is incorrect.

    The CT version should start up as an almost empty file, except for line #1 and then filters are added to it as required. So WP picks up the default from the core and amends it with the CT code.

    More technical details here.

    Thread Starter johnm92008

    (@johnm92008)

    Thank you that worked perfectly.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Where to Add Customizr Child Javascript’ is closed to new replies.