Home › Forums › Calendar Products › Events Calendar PRO › Increase Word Count on ListView
- This topic has 14 replies, 2 voices, and was last updated 8 years, 4 months ago by George.
-
AuthorPosts
-
December 14, 2015 at 1:33 pm #1041174JustinParticipant
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!
December 15, 2015 at 7:10 am #1041664GeorgeParticipantHey @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,
GeorgeDecember 15, 2015 at 11:14 am #1041844JustinParticipantHi 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!
December 16, 2015 at 7:29 am #1042310GeorgeParticipantHey @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!
GeorgeDecember 16, 2015 at 9:16 pm #1042629JustinParticipantThis reply is private.
December 17, 2015 at 9:20 am #1043015GeorgeParticipantThank 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!
December 17, 2015 at 9:59 am #1043033JustinParticipantGreat, that works perfectly – thank you!!!
December 18, 2015 at 8:57 am #1043645JustinParticipantHello – 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!
December 18, 2015 at 9:33 am #1043661JustinParticipantAdditionally, links from the event content are not coming through in the excerpts either, and we would like those to render properly as well
December 21, 2015 at 1:34 pm #1044859GeorgeParticipantHey 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,
GeorgeDecember 21, 2015 at 2:38 pm #1044883JustinParticipantHi 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?
December 21, 2015 at 2:41 pm #1044884JustinParticipantAlso, 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?
December 31, 2015 at 3:17 pm #1048618GeorgeParticipantHi 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:
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,
GeorgeJanuary 5, 2016 at 12:36 am #1050246JustinParticipantHi 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!
January 6, 2016 at 6:14 am #1051165GeorgeParticipantHey 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 -
AuthorPosts
- The topic ‘Increase Word Count on ListView’ is closed to new replies.