I’ve used a small javascript file to create an off canvas push navbar. I loaded the file as described in the Wordpres Codex:
function sidebar () {
wp_enqueue_script('theme-js', get_stylesheet_directory_uri() . '/js/nav-sidebar.js',array( 'jquery' ),$version,true );
}
add_action('wp_enqueue_scripts', 'sidebar');
However, it seems that the only js that is loaded is the nav-sidebar and the bootstrap.js refuses to load. If i remove nav-sidebar.js, bootstrap.js loads just fine. It creates a conflict that i can’t solve.
You can find the script i’ve used here
Expanding @RRikesh comment, you might have enqueued/loaded the bootstap.js
with same handle theme-js
. So only one script gets enqueued.
Try to use different handle for example nav-sidebar
. See the following code. Also it’s recommended to use prefix, here I used wpse
. Also use get_template_directory_uri
instead of get_stylesheet_directory_uri()
if it’s not a child theme.
function wpse_sidebar () {
wp_enqueue_script('nav-sidebar', get_template_directory_uri() . '/js/nav-sidebar.js',array( 'jquery' ),'1.0.0',true );
}
add_action('wp_enqueue_scripts', 'wpse_sidebar');