Home › Forums › Calendar Products › Events Calendar PRO › Limit the Words or Chars in the Excerpt
- This topic has 8 replies, 2 voices, and was last updated 8 years, 2 months ago by
kelly ann jones.
-
AuthorPosts
-
February 2, 2018 at 8:36 am #1442520
kelly ann jones
ParticipantI 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,
KellyFebruary 4, 2018 at 9:25 am #1443643kelly ann jones
ParticipantAnyone?
February 5, 2018 at 11:18 am #1444418Barry
MemberHi 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!
February 5, 2018 at 4:32 pm #1444669kelly ann jones
ParticipantThank 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.
KellyFebruary 5, 2018 at 5:20 pm #1444710Barry
MemberYou 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 );February 5, 2018 at 5:25 pm #1444718kelly ann jones
ParticipantLooks great! Thank you Barry!
February 5, 2018 at 5:29 pm #1444726Barry
MemberYou’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!
February 27, 2018 at 8:35 am #1464983Support Droid
KeymasterHey 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 -
AuthorPosts
- The topic ‘Limit the Words or Chars in the Excerpt’ is closed to new replies.
