Home › Forums › Calendar Products › Events Calendar PRO › Reduce the length of event excerpt text shown in event listing templates
- This topic has 6 replies, 3 voices, and was last updated 9 years, 6 months ago by
Hunter.
-
AuthorPosts
-
September 29, 2016 at 1:21 pm #1170669
Rupert
ParticipantHello,
Is there a filter I can use for this please? Or some other way to achieve it?
Thanks,
ShaunSeptember 29, 2016 at 3:48 pm #1170759Hunter
ModeratorShaun,
Thank you for reaching out! Try adding the following snippet to the bottom of your theme’s functions.php file and let me know if the list view description length changes as desired. Feel free to adjust the number value in the snippet to your liking. Cheers!
add_filter( 'excerpt_length', 'tribe_excerpt_length' );
function tribe_excerpt_length() {
return '60';
}September 30, 2016 at 2:49 am #1170916Rupert
ParticipantHi Hunter,
Thanks very much for the suggestion, but unfortunately that method isn’t having any effect.
The template displaying the excerpts in lists of events is list/single-event.php which I have duplicated into my child theme from the plugin directory. The line showing the excerpt is:
<?php echo tribe_events_get_the_excerpt( null, wp_kses_allowed_html( ‘post’ ) ); ?>
This pulls content from the post’s excerpt field if there is anything in that field, otherwise it looks at the post’s main content. Either way, the length of the text displayed is not being affected by the filter function which I have added exactly as from your message into my child theme’s functions.php.
I hope this helps to clarify what I need to do – is there anything else which I can try?
Many thanks,
Shaun (on behalf of my client Rupert)September 30, 2016 at 4:45 pm #1171294Hunter
ModeratorShaun,
Sorry to hear it’s not working out as planned. Try this snippet out as I had success with it earlier today:
function custom_excerpt_length( $length ) {
return 20;
}
add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );Let me know if this one does the trick and have a great weekend!
October 3, 2016 at 4:09 am #1171742Rupert
ParticipantHi Hunter,
Thanks very much for your suggestion which has fixed the issue.
Changing the priority setting on the add_filter() function to a much lower priority (eg 999 as in your suggestion) did the trick. I’m not exactly sure why, perhaps the theme or another plugin is also trying to manipulate the excerpt and giving the custom function a lower priority means it’s not affected by whatever anything else is trying to do with it.
Interestingly, the filter has no effect if the event post has an actual excerpt, ie text in the Excerpt field in the post editor. The filter only works if the template is creating the excerpt from the post content.
Thanks very much for your help with this,
ShaunOctober 3, 2016 at 10:31 pm #1172075Hunter
ModeratorShaun,
I believe if you have an excerpt in the add/edit event ‘Excerpt’ field, it overwrites the filter. I’m glad the workaround provided is working and please feel free to open a new thread if you have any more questions or concerns. Cheers!
-
AuthorPosts
- The topic ‘Reduce the length of event excerpt text shown in event listing templates’ is closed to new replies.
