Basic Collapsible
- Collapsibles are useful when you want to hide and show large amount of content:
Add bootstrap Library to your WordPress Functions.php
function my_js_scripts() { /** * Use latest jQuery and bootstrap Libs */ if( !is_admin() ){ wp_deregister_script('jQuery'); wp_deregister_script('bootstray'); wp_deregister_script('localLib'); wp_register_script('jQuery', "https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"); wp_enqueue_script('jQuery'); wp_register_script('bootstrab', "https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"); wp_enqueue_script('bootstrab'); /* local Lib depends heavily on Jquery - 3rd. param */ wp_enqueue_script('localLib', get_stylesheet_directory_uri().'/scripts/myJSLib.js', array('jquery'),'0.9', false ); wp_enqueue_script('localLib'); } } function my_css_style() { /* wp_enqueue_style( 'style-name', get_stylesheet_uri() ); //This is for getting style.css of current theme */ wp_register_style( 'cssStyles', get_template_directory_uri() .'css/genericCSS.css'); wp_enqueue_style( 'cssStyles' ); wp_register_style( 'bootstrapStyles', 'https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css'); wp_enqueue_style( 'bootstrapStyles' ); } add_action( 'wp_enqueue_scripts', 'my_js_scripts' ); add_action( 'wp_enqueue_scripts', 'my_css_style' );
HTML Test Code
Simple Collapsible
Click on the button to toggle between showing and hiding content.
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
Test HTML Code
Simple Collapsible
Click on the button to toggle between showing and hiding content.
Lorem ipsum dolor sit amet, consectetur adipisicing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.