Event excerpt length function removes Venue excerpt

Home Forums Calendar Products Events Calendar PRO Event excerpt length function removes Venue excerpt

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1342243
    Tim
    Participant

    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 😀

    #1342707
    Victor
    Keymaster

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

    #1342938
    Tim
    Participant

    Thanks 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.

    #1343379
    Victor
    Keymaster

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

    #1353548
    Support Droid
    Keymaster

    Hey 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

Viewing 5 posts - 1 through 5 (of 5 total)
  • The topic ‘Event excerpt length function removes Venue excerpt’ is closed to new replies.