Skip to content

Instantly share code, notes, and snippets.

@joshfeck
Created December 1, 2016 18:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joshfeck/caf106f86444cca8cefab74160ea5452 to your computer and use it in GitHub Desktop.
Save joshfeck/caf106f86444cca8cefab74160ea5452 to your computer and use it in GitHub Desktop.
Customize the EE4 calendar category legend using bit of inline JavaScript. You can add this code to a custom plugin http://eventespresso.com/wiki/create-site-specific-plugin-wordpress-site/ or into your WordPress theme's functions.php file.
<?php
//* Please do NOT include the opening php tag, except of course if you're starting with a blank file
//* The example below moves the 4th category to position 1 and the 3rd category to position 4
function ee_custom_category_legend_order(){
wp_add_inline_script(
'espresso_calendar',
'jQuery( document ).ready(function($) {
var options = $("#ee-category-legend-ul .has-sub");
$( options[ 3 ] ).insertBefore( $(options[ 0 ] ) );
$( options[ 2 ] ).insertAfter( $(options[ 3 ] ) );
} );'
);
}
add_action( 'wp_enqueue_scripts', 'ee_custom_category_legend_order', 11 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment