• Resolved pdopchev

    (@pdopchev)


    Hi guys,

    Is there a way to shorten the title of the events when the calendar is displayed in a “month view”?

    Thank you,
    Petar

    The page I need help with: [log in to see the link]

Viewing 5 replies - 1 through 5 (of 5 total)
  • Hi @pdopchev,

    Thanks for your interest in our products.

    This can definitely be done with a snippet like this added to your functions.php file:

    /*
     * 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' );

    Take care,
    Ed ??

    Thread Starter pdopchev

    (@pdopchev)

    Thank you for your quick reply. The code above actually breaks the website…

    That’s strange, if copied entirely this shouldn’t break the site — I tested on mine and was fine. I’d double check that you copied it entirely and didn’t place it inside an existing code bracket within functions.php.

    Alternatively, you could do this with custom templates following our Themer’s Guide — but using a filter like above is definitely easier.

    Thread Starter pdopchev

    (@pdopchev)

    Just re-added it and it works great! Thank you so much for your help, appreciate it!

    Awesome! Glad you got it figured out.

    I’m going to go ahead and close out this thread — don’t hesitate to create a new one any time you need help!

    Take care,
    Ed ??

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Shorten event title in month view’ is closed to new replies.