Skip to content

Instantly share code, notes, and snippets.

@Edwardtonnn
Last active January 26, 2018 17:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Edwardtonnn/e569750f9b09aca1ac521990e89b416b to your computer and use it in GitHub Desktop.
Save Edwardtonnn/e569750f9b09aca1ac521990e89b416b to your computer and use it in GitHub Desktop.
Adding jQuery to WordPress Avada Child Theme
(function($) {
$(document).ready(function() {
$('.newHover').hover(
function(){
jQuery( "a", this).toggleClass("white");
});
})
})(jQuery);
<?php
//this goes in functions.php near the top
add_action('wp_enqueue_scripts', 'my_scripts_method');
function my_scripts_method() {
// register your script location, dependencies and version
wp_register_script('custom_script',
get_stylesheet_directory_uri() . '/js/newHover-script.js',
array('jquery'),
'1.0' );
// enqueue the script
wp_enqueue_script('custom_script');
}
function theme_enqueue_styles() {
wp_enqueue_style( 'avada-parent-stylesheet', get_template_directory_uri() . '/style.css' );
}
add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
function avada_lang_setup() {
$lang = get_stylesheet_directory() . '/languages';
load_child_theme_textdomain( 'Avada', $lang );
}
add_action( 'after_setup_theme', 'avada_lang_setup' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment