Home › Forums › Calendar Products › Events Calendar PRO › Event excerpt length function removes Venue excerpt
- This topic has 5 replies, 2 voices, and was last updated 6 years, 7 months ago by Tim.
-
AuthorPosts
-
August 30, 2017 at 3:47 am #1342243TimParticipant
Hi, I want to adjust the length of the event excerpt so I used the function in this thread: https://theeventscalendar.com/support/forums/topic/event-descriptionexcerpt-length/
However when I do this is completely removes the excerpt on Venues in our archive pages for venues like this one: http://www.experienceoxfordshire.org/things-to-do/museums-in-oxfordshire/
Is there a way to limit the excerpt length on events only and not venues?
Thanks 😀
August 30, 2017 at 1:58 pm #1342707VictorKeymasterHi Tim!
Thanks for reaching out to us! Let me try to help you with that.
Try using the following code snippet instead and see if it helps:
// Changes the escerpt length for events to 100 words function custom_excerpt_length( $length ) { if( tribe_is_event() && is_archive() && ! tribe_is_venue() && ! is_post_type_archive('tribe_venue') ) { return 100; } } add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );
Let me know about it.
Best,
VictorAugust 31, 2017 at 1:21 am #1342938TimParticipantThanks Victor but I’m afraid it didn’t help 🙁
Just to be clear, I need the event excerpt to be 40 words but the venue excerpt to be 90. FYI I have the following code in my functions file already so I assume this must be causing the problem?
function get_ecommerce_excerpt(){ $excerpt = get_the_excerpt(); //$excerpt = preg_replace(" ([.*?])",'',$excerpt); $excerpt = strip_shortcodes($excerpt); $excerpt = strip_tags($excerpt); $excerpt = substr($excerpt, 0, 90); $excerpt = substr($excerpt, 0, strripos($excerpt, " ")); //$excerpt = trim(preg_replace( '/s+/', '', $excerpt)); return $excerpt; } function new_excerpt_more( $more ) { return '...'; } add_filter('excerpt_more', 'new_excerpt_more');
I’ve also attached a screen grab so you can see what is happening to our venue excerpts.
August 31, 2017 at 3:11 pm #1343379VictorKeymasterHi Tim!
I’m sorry that didn’t help.
First, please note we are fairly limited in how much support we can give for custom development questions like that.
That said, we always like helping out and at least point users into the right direction as much possible.
In the code you sent, you are using the excerpt_more filter. That filter will change the excerpt more string and not the length of the excerpt.
I can also see you have a custom function called get_ecommerce_excerpt(). If the template from the screenshot uses that function to print the excerpt, then you should bear in mind that the excerpt_length filter will apply to the get_the_excerpt().
You can use the following code as a reference and customize it to suit your needs:
// Changes the escerpt length for events and venues function custom_excerpt_length( $length ) { if( tribe_is_event() && is_archive() ) { return 10; } elseif ( tribe_is_venue() || is_post_type_archive('tribe_venue') ) { return 90; } } add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );
I hope that helps! Let me know if you have other questions.
Best,
VictorSeptember 22, 2017 at 9:35 am #1353548Support DroidKeymasterHey 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 ‘Event excerpt length function removes Venue excerpt’ is closed to new replies.