Increase Word Count on ListView

Home Forums Calendar Products Events Calendar PRO Increase Word Count on ListView

Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #1041174
    Justin
    Participant

    Hello,

    Can you please tell us how we can increase the word count for single events in ListView?

    We have tried following the instructions in this thread: https://theeventscalendar.com/support/forums/topic/limiting-word-count-on-listview/

    However there does not seem to be an exact answer to this question there, and within the single-event.php file we do not see anything related to the word count specifically.

    Thank you!

    #1041664
    George
    Participant

    Hey @Justin,

    In that file you will see this line of code around line 69:

    <?php echo tribe_events_get_the_excerpt(); ?>

    This is the code you can replace like Brian originally recommended in that old forum thread (he mentions a function the_excerpt(), but that function is now the above-mentioned tribe_events_get_the_excerpt()).

    Alternatively, you can just add a function like this to your theme’s functions.php file:


    add_filter( 'excerpt_length', 'tribe_support_1041174' );

    function tribe_support_1041174( $length ) {
    return 100;
    }

    ↑ That above code will change the excerpt length to 100 words. You can use any digit other than 100, of course, so play around to find the perfect word count.

    Cheers,
    George

    #1041844
    Justin
    Participant

    Hi George,

    Thank you for your response here. However, when we add the function you’ve referenced, it doesn’t seem to change the Calendar List View excerpts at all (they are still the default length).

    The only thing that it seems to change is the excerpts on our blog. But we don’t want this to affect the excerpts on our blog at all.

    Is there a function we can use that will change only the length of the excerpts in the Calendar List View, without affecting blog excerpts?

    Thank you!

    #1042310
    George
    Participant

    Hey @Justin,

    Sorry to hear about this – can you share your System Information as described in this article? β†’ https://theeventscalendar.com/knowledgebase/sharing-sys-info/

    I will take a look at that and double-check my code with this information in mind, then recommend something better πŸ™‚

    Cheers!
    George

    #1042629
    Justin
    Participant

    This reply is private.

    #1043015
    George
    Participant

    Thank you for this Justin!

    After some tinkering, I found that this code works:


    add_action( 'wp', 'tribe_support_clear_excerpt_length' );

    function tribe_support_clear_excerpt_length() {
    remove_all_filters( 'excerpt_length', 0 );
    }

    add_filter( 'excerpt_length', 'tribe_support_1041174', 9999 );

    function tribe_support_1041174( $length ) {

    if ( tribe_is_event() ) {
    $length = 5;
    }

    return $length;
    }

    Where you see this:

    $length = 5;

    Change that to whatever number of words you want πŸ™‚

    I hope this helps!

    #1043033
    Justin
    Participant

    Great, that works perfectly – thank you!!!

    #1043645
    Justin
    Participant

    Hello – we have an additional question regarding the List View excerpts:

    Is there a way that we can have the List View excerpts not strip out formatting from the content (such as text formatting and paragraphs)? We would very much like to have our excerpts keep any text formatting and paragraphs that are contained within the original content.

    Thank you!

    #1043661
    Justin
    Participant

    Additionally, links from the event content are not coming through in the excerpts either, and we would like those to render properly as well

    #1044859
    George
    Participant

    Hey Justin,

    One thing that might help is to add this snippet to your theme’s functions.php file β†’ https://gist.github.com/ggwicz/ba85b0f9aa4dadbda538

    Cheers,
    George

    #1044883
    Justin
    Participant

    Hi George,

    Thank you – that code does seem to now preserve the HTML styles and links.

    The only thing that is not coming through new are the paragraphs. The paragraphs are not being written into the HTML manually, but rather are automatically created by WordPress.

    Is there any way to get the paragraphs to come through properly as well? Or can they somehow not be rendered because WordPress automatically adds them into the page content?

    #1044884
    Justin
    Participant

    Also, this function is now also affecting how our Blog excerpts appear.

    We only wanted to make this change to our Calendar List View excerpts, not our Blog excerpts.

    Is there something we can change to the code here to make this change only affect the Calendar List View excerpts and not the Blog excerpts?

    #1048618
    George
    Participant

    Hi Justin,

    Thank you for your patience with our delayed responses over the holidays!

    Unfortunately I cannot come up with a solution for this first question of yours, regarding the paragraph issues:

    Is there any way to get the paragraphs to come through properly as well? Or can they somehow not be rendered because WordPress automatically adds them into the page content?

    When you say “properly”, I don’t quite know what you mean, and in any case the tags are indeed auto-generated by a function within WordPress core πŸ™

    As for the second part of your question, about limiting this stuff to only happen for events, I’ve made changes to the original Gist code here, check it out:

    http://git.io/vufmJ

    If you replace the most recent code I shared with you before this reply, with the code I shared right here in this reply, then the filter should only really “do anything” if the piece of content being filtered is an event.

    If further tweaks and modifications are desired from here on, I unfortunately will not be able to provide custom coding support πŸ™ We are constantly working on plugin improvements though, and any additional feedback about our excerpts system is much appreciated (and will help us fix things in our next releases!).

    Cheers,
    George

    #1050246
    Justin
    Participant

    Hi George,

    Thank you for updating the function to prevent it from applying to excerpts outside of The Events Calendar.

    However, I if anyone else is going to reference/use this function, I would just like to point out that I think there is a small syntax error:

    The first line should be: if ( function_exists( ‘tribe_get_events’ ) ) {

    Instead of if ( function_exists( ‘tribe_get_events’ ) ) :

    At least that is what worked for us, as there seemed to be a syntax error otherwise.

    By having the paragraphs “come through properly”, we meant having them come through at all. We think that having paragraphs come through in the excerpts is something that would make the excerpts look much better and be more readable. After all, the more that the Calendar List View excerpts can look like the actual content from their corresponding event, the better.

    Should I make this suggestion through your suggestion portal, or is this something that is not reasonable to ask (since up until this thread there hasn’t seemed to be much attention paid to the display of the Calendar List View excerpts at all, so perhaps this is not a priority for your team)?

    Thank you!

    #1051165
    George
    Participant

    Hey Justin,

    Wow, I indeed made a typo in that Gist – how embarrassing! I’ve corrected that on the Gist in case anyone else stumbles across it, since it’s a public Gist.

    Good catch, thank you for sharing it πŸ™‚

    As for the paragraphs-in-excerpts, it seems like you mean literal “P” paragraph HTML tags – I think this is definitely something worth noting on our UserVoice page here β†’ http://tribe.uservoice.com

    Excerpts have unfortunately become trickier to work with over time, and at this time, in my opinion, we are just not handling them as robustly as we could be. This is not a fault of our developers – in fact, they’ve improved things substantially in the last few releases alone. But we’ve still got some work to do with the excerpts in The Events Calendar function, so please do share any thoughts on that page (or, if you see existing thoughts there, “upvote” them to increase our awareness of them!).

    Thanks for your patience with these issues, and with my code typos πŸ™‚

    I’ll close up this thread for the time being, but if any other questions, comments, or concerns arise, open a new thread any time!

    Cheers,
    George

Viewing 15 posts - 1 through 15 (of 15 total)
  • The topic ‘Increase Word Count on ListView’ is closed to new replies.