Created
May 22, 2013 19:35
-
-
Save stephenharris/5630266 to your computer and use it in GitHub Desktop.
Prints colours of event categories to header on front-end
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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