lizardking8610
5/18/2017 - 6:04 PM

jQuery: multiple accordions on 1 wordpress page

jQuery: multiple accordions on 1 wordpress page

jQuery( function($) {
$( "#accordion:nth-child(1n)" ).accordion({
collapsible: true,
active: false,
heightStyle: "content"
});
} );
  
/* You'll need to add this enqeue script to your functions.php file to have the jQuery script load */

function my_scripts_method() {
if ( !is_admin() ) {
	wp_enqueue_script('jquery-ui-accordion');
	wp_enqueue_script(
		'custom-accordion',
		get_stylesheet_directory_uri() . '/js/accordion.js',
		array('jquery')
		);
	
  /*unrelated script for tabs */
  wp_enqueue_script('jquery-ui-tabs');
	wp_enqueue_script(
		'custom-tabs',
		get_stylesheet_directory_uri() . '/js/tabs.js',
		array('jquery')
		);
	
	}
}
add_action('wp_enqueue_scripts', 'my_scripts_method');


wp_register_style('jquery-custom-style', get_stylesheet_directory_uri().'/css/jquery-ui-1.12.1.custom/jquery-ui.css', array(), '1', 'screen'); 
wp_enqueue_style('jquery-custom-style');