Last active
March 4, 2016 13:28
-
-
Save elimn/f34c591aa307c901711c to your computer and use it in GitHub Desktop.
MT | TEC | Truncate event titles in Month (Grid) view
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 | |
| /* | |
| * Truncates event titles in Month (Grid) view | |
| */ | |
| function tribe_month_event_title_truncator( $title, $id = null ) { | |
| $is_month_ajax = ( defined( 'DOING_AJAX' ) && DOING_AJAX && tribe_is_month() ); | |
| $is_month_main = ( is_main_query() && tribe_is_month() ); | |
| if ( ! $is_month_ajax && ! $is_month_main ) return $title; | |
| // Max length of event title | |
| $length = 30; | |
| return ( strlen( $title ) > $length ) ? substr( $title, 0, $length - 3 ) . '…' : $title; | |
| } | |
| add_filter( 'the_title', 'tribe_month_event_title_truncator' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment