Reduce the length of event excerpt text shown in event listing templates

Home Forums Calendar Products Events Calendar PRO Reduce the length of event excerpt text shown in event listing templates

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1170669
    Rupert
    Participant

    Hello,

    Is there a filter I can use for this please? Or some other way to achieve it?

    Thanks,
    Shaun

    #1170759
    Hunter
    Moderator

    Shaun,

    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';
    }

    #1170916
    Rupert
    Participant

    Hi 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)

    #1171294
    Hunter
    Moderator

    Shaun,

    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!

    #1171742
    Rupert
    Participant

    Hi 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,
    Shaun

    #1172075
    Hunter
    Moderator

    Shaun,

    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!

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Reduce the length of event excerpt text shown in event listing templates’ is closed to new replies.