I'm having some issues in loading a custom jquery slider into a wordpress site I'm working on: I'm not super proficient with theme development but I'm studying hard and I spent lots of days trying with no result.
I'm using the beaver builder for the graphical aspect but I'd like to insert a content slider (which in the free version is not provided). I tried to use a ready jquery content slider called anyslider.
My issue is that I'm not sure I'm loading the jquery scripts properly: thi is how I edited the functions.php file of my child theme:
<?php
add_action( 'wp_enqueue_scripts' ,'enqueue_parent_theme_style' );
function enqueue_parent_theme_style() {
wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );
if (!is_admin()) add_action("wp_enqueue_scripts", "my_jquery_enqueue", 11);
function my_jquery_enqueue() {
wp_deregister_script('jquery');
wp_register_script('jquery', "http" . ($_SERVER['SERVER_PORT'] == 443 ? "s" : "") . "://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js", false, null);
wp_enqueue_script('jquery');
function add_my_script() {
wp_enqueue_script(
'anyslider',
get_template_directory_uri() . '/js/jquery.anyslider.js',
array('jquery')
);
wp_enqueue_script(
'anyslider_easing',
get_template_directory_uri() . '/js/jquery.easing.1.3.js',
array('jquery','anyslider')
);
}
add_action( 'wp_enqueue_scripts', 'add_my_script' );
I tried to follow every tutorial I found by the book what am i doing wrong?
EDIT
I edited the functions.php file like this: now it's working, thanks everybody
<?php
add_action( 'wp_enqueue_scripts' ,'enqueue_parent_theme_style' );
function enqueue_parent_theme_style() {
wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );
}
if( !is_admin() ){
wp_deregister_script('jquery');
wp_register_script('jquery', ("http://code.jquery.com/jquery-latest.min.js"), false, '');
wp_enqueue_script('jquery');
}
add_action('wp_enqueue_scripts', 'mytheme_custom_scripts');
if (wp_script_is('jquery')) echo "<h1>IT WORKS!</h1>";
alert()
wil also work in plain javascript without jquery. I'd double check that. Are you sure the enqueued scripts work with the jquery version you load? You could also trywp_script_is
my_jquery_enqueue
function at all, where did that come from..? you should let wordpress enqueue jquery unless you have a very very specific reason and even then it's not the best idea...