Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1339412

    I’m trying to overwrite the “avia-snippet-lightbox.js” activation and the “avia-snippet-megamenu.js” in my child theme but without success. What I got so far from the forum was:

    function wp_change_lightbox_activation_js() {
    	wp_dequeue_script( 'avia-lightbox-activation-js', get_template_directory().'/js/avia-snippet-lightbox.js', array('jquery'));
    	wp_deregister_script( 'avia-lightbox-activation-js', get_template_directory().'/js/avia-lightbox-activation-js', array('jquery'));
    	wp_enqueue_script( 'child-lightbox-activation-js', get_stylesheet_directory_uri().'/js/avia-lightbox-activation-js', array('jquery'));
    	
    	}
    	add_action( 'wp_enqueue_scripts', 'wp_change_lightbox_activation_js', 100 );

    This brings zero effect. Is there a solution? Thanks for your help.

    • This topic was modified 2 years, 10 months ago by conflock.
    #1339532

    Hey conflock,

    Thank you for the inquiry.

    The wp_deregister_script only accepts one parameter or argument, which is the script name or handle, so the code above is invalid. You should also check the file name and its path.

    Did you copy the avia-snippet-megamenu.js and the avia-snippet-lightbox.js files in the js folder of the child theme directory? Please try to replace the code with this one.

    function ava_change_wp_enqueue_scripts_mod() {
        wp_deregister_script( 'avia-lightbox-activation' );
        wp_deregister_script( 'avia-megamenu' );
    	wp_enqueue_script( 'avia-child-lightbox-activation', get_stylesheet_directory_uri() . '/js/avia-snippet-lightbox.js', array('jquery'));
        wp_enqueue_script( 'avia-child-megamenu', get_stylesheet_directory_uri() . '/js/avia-snippet-megamenu.js', array('jquery'));
    }
    add_action( 'wp_enqueue_scripts', 'ava_change_wp_enqueue_scripts_mod', 100 );
    

    Make sure that the script files is in the child theme’s js folder.

    Best regards,
    Ismael

    #1339625

    Thanks a lot!!!

    #1339698

    Hi,

    Great, I’m glad that Ismael could help you out. Please let us know if you should need any further help on the topic or if we can close it.

    Best regards,
    Rikard

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