• I’m trying to write a jquery script that will affect some elements inside of a widget on the footer. I tried writting it on the widget itself and on sidebar-footer.php, but neither of those worked. I tried it on the browser console, it it didn’t work either. I got a “TypeError: undefined is not a function”.

    I’m a little confused. I looked at my code and I see the jquery library being called by some of the plugins at the bottom of the page:

    <link rel='stylesheet' id='metaslider-display-css-css'  href='https://mysite.com/wp-content/plugins/ml-slider/assets/metaslider/public.css?ver=2.0.1' type='text/css' media='all' />
    <link rel='stylesheet' id='metaslider-nivo-slider-css-css'  href='https://mysite.com/wp-content/plugins/ml-slider/assets/sliders/nivoslider/nivo-slider.css?ver=3.5.1' type='text/css' media='all' />
    <link rel='stylesheet' id='ml-slider_nivo_slider_theme_default-css'  href='https://mysite.com/wp-content/plugins/ml-slider/assets/sliders/nivoslider/themes/default/default.css?ver=3.5.1' type='text/css' media='all' />
    <script type='text/javascript' src='https://mysite.com/wp-includes/js/jquery/jquery.js?ver=1.8.3'></script>
    <script type='text/javascript' src='https://mysite.com/wp-content/plugins/ml-slider/assets/easing/jQuery.easing.min.js?ver=2.0.1'></script>
    <script type='text/javascript' src='https://mysite.com/wp-content/plugins/ml-slider/assets/sliders/nivoslider/jquery.nivo.slider.pack.js?ver=2.0.1'></script>
    
    </body>
    </html>

    and yet I cannot seem to use it anywhere on the site or on the browser console.

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    You must enqueue your script using wp enqueue script() in the appropriate action hook function. One of the parameters passed to the function is an array of dependencies, which needs to at least contain ‘jquery’. This PHP code can be placed in your theme’s functions.php file, but to avoid the need to reinsert the code upon any theme update, it’s worth creating a simple child theme.

Viewing 1 replies (of 1 total)
  • The topic ‘Writting jquery script on widget’ is closed to new replies.