Limit the Words or Chars in the Excerpt

Home Forums Calendar Products Events Calendar PRO Limit the Words or Chars in the Excerpt

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1442520
    kelly ann jones
    Participant

    I just purchased the PRO version of the calendar and I need to know how to limit the amount of content shown in the list view excerpt. I have list view embedded on a page and the list is too long due to amount of content shown.

    Is it possible to limit the amount shown?

    Thank you,
    Kelly

    #1443643
    kelly ann jones
    Participant

    Anyone?

    #1444418
    Barry
    Member

    Hi Kelly,

    Sorry first of all for the delay.

    This is certainly possible and one way you can approach this is with some custom code, which can be added either to a custom plugin (preferred) or else to your theme’s functions.php file:

    add_filter( 'excerpt_length', function() { return 20; }, 1000 );

    In the above example, it should reduce the length of the excerpt text to no more than 20 words (you can adjust 20 to whatever makes sense for you, however).

    It’s worth highlighting however that this will only work if WordPress is autogenerating the excerpt: generally speaking, just as is typically the case for regular blog posts, if a full description is provided and nothing else then the excerpt will be created automatically and the above snippet should work.

    However, if you have added a manually crafted excerpt, the above technique quite deliberately will not work and the best policy is instead to edit the excerpt via the event editor screen.

    I hope that helps but if you have any further questions please do let me know (and if you can link to some live examples – should that help us to understand the situation in the context of your own site – please do, using our private reply functionality if you prefer).

    Thanks!

    #1444669
    kelly ann jones
    Participant

    Thank you for the response. Adding the code above to my functions file, my preferred method, will shorten the calendar excerpt, but unfortunately it will also shorten the excerpt length I have already assigned for regular posts. I was hoping for a shortcode that generated the truncated copy or a filter that was specific to the calendar plugin.

    I will instruct my client to add the excerpt field at the time of creation from here on out.

    Thank you for your time.
    Kelly

    #1444710
    Barry
    Member

    You could certainly make it a little more restrictive — how about this alternative snippet?

    add_filter( 'excerpt_length', function( $length ) {
        return function_exists( 'tribe_is_list_view' ) && tribe_is_list_view()
            ? 20
            : $length;
    }, 1000 );
    #1444718
    kelly ann jones
    Participant

    Looks great! Thank you Barry!

    #1444726
    Barry
    Member

    You’re welcome 🙂

    I’ll leave this open for the time being in case you have any follow-up questions on this (though it’s appreciated if – for separate/unrelated problems – you can create a fresh topic, just to keep things clean and organized).

    Thanks again for bearing with us!

    #1464983
    Support Droid
    Keymaster

    Hey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.

    Thanks so much!
    The Events Calendar Support Team

Viewing 8 posts - 1 through 8 (of 8 total)
  • The topic ‘Limit the Words or Chars in the Excerpt’ is closed to new replies.