jQuery don’t load for a child theme in WordPress

I would like to add an HTML code in my child theme to add an icon in my child theme in WordPress. Currently, that’s like that :

First

Read More

And I would like to add a Youtube icon like that (that’s not in the theme, that’s why I want to add it with HTML) :

Second

So I set up the function.php code with :

    <?php

function mytheme_scripts() {
wp_enqueue_script('mytheme_functions', get_stylesheet_directory_uri().'/js/myScript.js', array('jquery'), '', true);
wp_enqueue_script('jq_ui', get_stylesheet_directory_uri().'/js/jquery-ui-1.10.3.custom.min.js', array('jquery')); //Not sure if we can use the CDN here instead of a local version.
}
add_action( 'wp_enqueue_scripts', 'mytheme_scripts' );

?>

Here is my jQuery code :

 $(document).ready(function($) { 

$(".social-google-plus").append('<li class="social-youtube"><a href="http://www.twitter.com/TWorldAngels" target="blank"><i class="fa fa-youtube"></i></a></li>');


});

My jQuery code is in a /js folder which is in my child theme. But it doesn’t work. What is wrong ? Thanks guys !

Related posts

1 comment

  1. I am quite sure that mine loads right.

    Perhaps the $ is generating the issue (is how WordPress prevents conflicts between js libraries).

    Try the following:

    jQuery(document).ready(function($) { 
        $(".social-google-plus").append('<li class="social-youtube"><a href="http://www.twitter.com/TWorldAngels" target="blank"><i class="fa fa-youtube"></i></a></li>');
    });
    

    (I haven’t tested your code)

    if this does not resolve it, can you provide further details? Console errors?

Comments are closed.