Skip to content

Instantly share code, notes, and snippets.

@stephenharris
Created May 22, 2013 19:35
Show Gist options
  • Save stephenharris/5630266 to your computer and use it in GitHub Desktop.
Save stephenharris/5630266 to your computer and use it in GitHub Desktop.
Prints colours of event categories to header on front-end
<?php
/**
* Prints colours of event categories to header on front-end
* @See http://wp-event-organiser.com/blog/tutorial/using-event-colours-in-your-theme/
* @See http://wp-event-organiser.com/blog/tutorial/adding-event-colour-to-your-menu/
*
*/
add_action( 'wp_print_styles', 'my_print_event_cat_colours' );
function my_print_event_cat_colours(){
$cats = get_terms( 'event-category' );
if( $cats ){
echo '<style>';
foreach( $cats as $cat ){
printf(
".event-category-%s{ background: %s;}\n",
sanitize_html_class( $cat->slug ),
eo_get_category_color( $cat )
);
}
echo '</style>';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment