Skip to content

Instantly share code, notes, and snippets.

Last active February 14, 2018 16:48
What would you like to do?
Add this to custom-fields-accordions.js
// See
jQuery(document).ready(function() {
// Close the panel and remove all classes when called.
function close_accordion_section() {
jQuery('#custom-fields-accordion .accordion-section').removeClass('active');
jQuery('#custom-fields-accordion .accordion-section-title').removeClass('active');
jQuery('#custom-fields-accordion .accordion-section-content').slideUp(300).removeClass('open');
jQuery('.accordion-section-title').click(function(e) {
// Store the clicked link
var currentAttrValue = jQuery(this).attr('href');
// If open when clicked, close it.
if(jQuery('.active')) {
else {
// If closed, clear all classes.
// Add active class to section title
// Open up the hidden content panel
jQuery('#custom-fields-accordion ' + currentAttrValue).slideDown(300).addClass('open');
// Add an active classs to the whole wrapper. Not used by default,
// but added for convenience.
// Don't try to follow the link.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment