Skip to content

Instantly share code, notes, and snippets.

@elimn
Last active March 4, 2016 13:28
Show Gist options
  • Select an option

  • Save elimn/f34c591aa307c901711c to your computer and use it in GitHub Desktop.

Select an option

Save elimn/f34c591aa307c901711c to your computer and use it in GitHub Desktop.
MT | TEC | Truncate event titles in Month (Grid) view
<?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 ) . '&hellip;' : $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