Home › Forums › Calendar Products › Events Calendar PRO › Custom excerpt length ignored after update
- This topic has 4 replies, 3 voices, and was last updated 7 years, 10 months ago by Josh.
-
AuthorPosts
-
June 27, 2016 at 9:05 am #1132382GabrielleParticipant
Hi there!
About a week ago I updated my functions.php file to create a custom length of my calendar excepts in list view. It contained an if/else statement that allowed for my blog post excerpts to be a different length than the calendar excerpts. This worked fine until I updated all the calendar plugins (4.2.1)
Right now this is my code that used to work:
if ( ! function_exists( 'custom_excerpt_length' ) ) { function custom_excerpt_length( $length ) { global $data; if ( !empty ( $data['blog_excerpt_limit'] ) ) { $excerpt = $data['blog_excerpt_limit']; } elseif (is_category()) { $excerpt = 55; } else { $excerpt = 20; } return $excerpt; } } if ( ! function_exists( 'clear_excerpt_more' ) ) { function clear_excerpt_more( $more ) { return '...'; } } add_filter('excerpt_more', 'clear_excerpt_more'); add_filter( 'excerpt_length', 'custom_excerpt_length', 999 ); if ( ! function_exists( 'zn_limit_content' ) ) { function zn_limit_content($string, $word_limit) { $words = explode(" ",$string); return implode(" ",array_splice($words,0,$word_limit)); } }
If I just use the code below suggested in other forums posts, it doesn’t effect any of my excerpts. However, it did before the update:
function custom_excerpt_length( $length ) { return 20; } add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );
Any thoughts on what might have changed?
Thanks so much!
- This topic was modified 7 years, 10 months ago by Gabrielle. Reason: spelling
June 27, 2016 at 1:34 pm #1132594JoshParticipantHey Shawn,
Thanks for reaching out to us!
In your initial excerpt length function, try using
if( !tribe_is_event_query() )
 instead ofif( is_category() )
and see if that works for you here. That will allow for any non-event based excerpt to display at 55 and the events to display at 20.Let me know if this helps.
Thanks!
June 30, 2016 at 6:32 am #1133907GabrielleParticipantHi there!
Turns out there was someone else populating the events on my team who was manually adding excerpts. Once I got them to remove those, my code worked just fine once again đŸ™‚ That code you provided looks much cleaner than what I have though, and I’m gonna give it a whirl. Thanks again!
July 1, 2016 at 7:07 pm #1134698JoshParticipantHey Shawn,
No problem, I’m glad you were able to find the issue here.
I’ll go ahead and close this thread for now. If you have any further questions, please don’t hesitate to open a new one.
Thanks!
-
AuthorPosts
- The topic ‘Custom excerpt length ignored after update’ is closed to new replies.