0

I don't know what I'm doing wrong... I'm using the starter timber theme... I'm trying unslider to work with my theme... indicated here is somehow a proof I did right in putting scripts from the function.php...

<script type='text/javascript' src='http://localhost/luxjeweler/wp-content/themes/timber-starter-theme-master/includes/js/jquery.js?ver=1'></script>
<script type='text/javascript' src='http://localhost/luxjeweler/wp-content/themes/timber-starter-theme-master/includes/resources/bootstrap/js/bootstrap.min.js?ver=1'></script>
<script type='text/javascript' src='http://localhost/luxjeweler/wp-content/themes/timber-starter-theme-master/includes/js/bootstrap-wp.js?ver=1'></script>
<script type='text/javascript' src='http://localhost/luxjeweler/wp-content/themes/timber-starter-theme-master/includes/js/skip-link-focus-fix.js?ver=1'></script>
<script type='text/javascript' src='http://localhost/luxjeweler/wp-content/themes/timber-starter-theme-master/includes/unislider/js/unslider-min.js?ver=1'></script>
<script type='text/javascript' src='http://localhost/luxjeweler/wp-content/themes/timber-starter-theme-master/includes/js/stickyFooter.js?ver=1'></script>
<script type='text/javascript' src='http://localhost/luxjeweler/wp-content/themes/timber-starter-theme-master/script.js?ver=1'></script>
<script type='text/javascript' src='http://localhost/luxjeweler/wp-includes/js/wp-embed.min.js?ver=4.4.2'></script>

but somehow jquery is not working... tried using the jquery enqueue default provided by wordpress and a custom enqueue but with no success... I tried testing by using this simple code:

$(document).ready(function(){
   alert("test");
}); 

no response when I refresh the page...

Edit (15-02-16):

This is my enqueue function:

function luxjewels_scripts() {

    // Import the necessary TK Bootstrap WP CSS additions
    wp_enqueue_style( 'luxjewels-bootstrap-wp', get_template_directory_uri() . '/includes/css/bootstrap-wp.css', false, '1');

    // load bootstrap css
    wp_enqueue_style( 'luxjewels-bootstrap', get_template_directory_uri() . '/includes/resources/bootstrap/css/bootstrap.css', false, '1' );

    // load Font Awesome css
    wp_enqueue_style( 'luxjewels-font-awesome', get_template_directory_uri() . '/includes/css/font-awesome.min.css', false, '1' );

    // load styles
    wp_enqueue_style( 'luxjewels-style', get_stylesheet_uri() );

    wp_enqueue_style( 'luxjewels-unslider', get_template_directory_uri() . '/includes/unslider/css/unslider.css', true, '1');



    wp_enqueue_script( 'luxjewels-jquery', get_template_directory_uri() . '/includes/js/jquery.js', array(), '1', true );

    // load bootstrap js
    wp_enqueue_script('luxjewels-bootstrapjs', get_template_directory_uri().'/includes/resources/bootstrap/js/bootstrap.min.js', array(), '1', true);

    // load bootstrap wp js
    wp_enqueue_script( 'luxjewels-bootstrapwp', get_template_directory_uri() . '/includes/js/bootstrap-wp.js', array(), '1', true);
    wp_enqueue_script( 'luxjewels-skip-link-focus-fix', get_template_directory_uri() . '/includes/js/skip-link-focus-fix.js', array(), '1', true );

    // load Unslider js and css
    wp_enqueue_style( 'luxjewels-unslider-dots', get_template_directory_uri() . '/includes/unslider/css/unslider-dots.css',  false, '1', true);

    wp_enqueue_script('luxjewels-unslider-min', get_template_directory_uri().'/includes/unslider/js/unslider-min.js', array(), '1', true);


    // load stickyfooter js
    wp_enqueue_script( 'luxjewels-stickyfooter', get_template_directory_uri() . '/includes/js/stickyFooter.js', array(), '1', true );

    // load custom js
    wp_enqueue_script( 'luxjewels-custom-script', get_template_directory_uri() . '/script.js', array(), '1', true );

}
add_action( 'wp_enqueue_scripts', 'luxjewels_scripts' );
  • tried using the jquery enqueue default provided by wordpress and a custom enqueue - could you please show us the code? – Mayeenul Islam Feb 15 '16 at 9:28
  • Added the whole function for enqueue... :) – Manson Mamaril Feb 15 '16 at 9:30
  • Instead of putting [Solved] in the title, please mark the answer that helped you, so other users can quickly find it, too. – flomei Feb 15 '16 at 14:37
  • Thanks for the tip... I'm really new to stackexchange... please forgive me... :) – Manson Mamaril Feb 15 '16 at 15:44
0
$(document).ready(function(){
   alert("test");
}); 

It could be that your jQuery is working in compatibility mode. Try replacing $ with jQuery:

jQuery(document).ready(function(){
   alert("test");
}); 

Edit: As per the author edit on the post:

jQuery(document).ready(function(){
   jQuery('.automatic-slider').unslider({
        autoplay: true
    });
}); 
  • Thanks!!! that does it! it's working... for the next problem... I don't know if this deserves to be on another post... unslider is not working... :) – Manson Mamaril Feb 15 '16 at 10:47
  • How are you calling the slider? – denis.stoyanov Feb 15 '16 at 11:09
  • Added the codes on the post above... :) – Manson Mamaril Feb 15 '16 at 12:43
  • @MansonMamaril Check the edit on the post and try replacing $('.automatic-slider').unslider({.... – denis.stoyanov Feb 15 '16 at 12:51
  • Thank you again... that worked... may I ask why not $ symbol anymore??? – Manson Mamaril Feb 15 '16 at 13:19
1

Remove this line:

wp_enqueue_script( 'luxjewels-jquery', get_template_directory_uri() . '/includes/js/jquery.js', array(), '1', true );

And replace the following line:

wp_enqueue_script( 'luxjewels-custom-script', get_template_directory_uri() . '/script.js', array(), '1', true );

with:

wp_enqueue_script( 'luxjewels-custom-script', get_template_directory_uri() . '/script.js', array('jquery'), '1', true );

Explanation:

The instead of loading our custom jQuery library, we can simply load jQuery from the core. And declaring dependency, we're doing this simply by modifying our second line of code.

  • no success... btw... if needed this is my folder structure... snag.gy/eiOaJ.jpg – Manson Mamaril Feb 15 '16 at 10:26
  • To debug things, please make things simple first. Then add one by one. I'd recommend the basic debugging technique for WordPress. And we can't provide support for any third party products, because the person knows about it mostly, is the author of the product. When adding your script, do the perfect dependency for a better queue of the scripts. – Mayeenul Islam Feb 15 '16 at 10:51
  • yes... thank you for the advice... if I may... I'll link the author to this post... so please don't bring this down... :) – Manson Mamaril Feb 15 '16 at 10:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.