Skip to content

Instantly share code, notes, and snippets.

@neilgee
Last active December 2, 2021 03:20
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save neilgee/aa2e1b1c59f078416899 to your computer and use it in GitHub Desktop.
Save neilgee/aa2e1b1c59f078416899 to your computer and use it in GitHub Desktop.
Sidr in WordPress
jQuery(document).ready(function($) {
$('#nav-toggle').sidr({
name: 'sidr-right',
side: 'right',
source: '#menu-short, .search-form, .site-title'
});
});
jQuery(document).ready(function($) {
$('#nav-toggle').sidr({
name: 'sidr-right', //name it
side: 'right', //position it
source: '' //add the content
});
});
jQuery(document).ready(function($) {
$('#nav-toggle').sidr({
name: 'sidr-right',
side: 'right',
source: '#menu-short, .search-form, .site-title'
});
$('#nav-toggle-left').sidr({
name: 'sidr-left',
side: 'left',
source: ''
});
});
<?php
//Script-tac-ulous -> All the Sidr JS and CSS files
function themeprefix_scripts_styles_sidr() {
wp_enqueue_script ( 'sidrjs' , get_stylesheet_directory_uri() . '/js/jquery.sidr.min.js', array( 'jquery' ), '1', true );
wp_enqueue_script ( 'sidrinit' , get_stylesheet_directory_uri() . '/js/sidr-init.js', array( 'sidrjs' ), '1', true );
wp_enqueue_style ( 'sidrcss-dark' , get_stylesheet_directory_uri() . '/css/jquery.sidr.dark.css', '', '1', 'all' );
//wp_enqueue_style ( 'sidrcss-light' , get_stylesheet_directory_uri() . '/css/jquery.sidr.light.css', '', '1', 'all' );
}
add_action( 'wp_enqueue_scripts', 'themeprefix_scripts_styles_sidr' );
<div id="mobile-icon">
<a id="nav-toggle" href="#sidr">MENU</a>
</div>
#mobile-icon {
display: none;
}
@media only screen and (max-width: 800px){/*change to desired width*/
#mobile-icon {
display: block;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment