Home Ask Login Register

Developers Planet

Your answer is one click away!

ute February 2016

Smooth Div Scroll jquery plugin for wordpress

the Smooth Div Scroll jquery plugin is exactly what i need for a wordpress site I am making. But I don't know how to add it to wordpress. The one answer I found in stackoverflow didn't work alas.

I am not a professional coder but can follow copy and paste instructions pretty well. :)

So: I have a child theme with a functions.php I understand I need to add something there but I don't know would love to find out exactly what. And then add files to the js folder but I don't know exactly what. And what about the css files?

Any help would be greatly appreciated! Thank you.


Joe Conlin February 2016

Here is the proper way to add scripts into your theme. Simply place the script in your [THEME]/js directory and copy the code below to your theme functions.php file. Make sure the code below is updated with the correct path to your script and you should be good to go!

function properly_add_your_scripts() {
    wp_register_script( 'smooth_div_scroll', get_template_directory_uri() . '/js/smoothDivScroll.js', array('jquery'), '1.0.0', true ); // True to add it in footer (recommended)

add_action( 'wp_enqueue_scripts', 'properly_add_your_scripts' );  

Post Status

Asked in February 2016
Viewed 1,274 times
Voted 9
Answered 1 times


Leave an answer

Quote of the day: live life