Home › Forums › Calendar Products › Events Calendar PRO › Display Excerpt in List View
- This topic has 14 replies, 3 voices, and was last updated 8 years, 5 months ago by
Julie.
-
AuthorPosts
-
November 2, 2017 at 11:41 am #1374004
Julie
ParticipantHi – I cannot figure out how to display the excerpt when in list view. I have tried to add different forms of truncated code to the functions file, added basic php to the functions file (seen below) to no avail. I’d love if it can work and look like the demo if I need to strip everything else. The site is on a custom WordPress theme, which is super basic. I checked for conflicts and it still doesn’t show. Please help!
code I have tested:
– added this to the functions file, in case it is being called, but truncated:
add_filter( ‘excerpt_length’, ‘custom_excerpt_length’, 999 ); function custom_excerpt_length( $length ) { return 300; }
– added this as a more general rule for WP on the functions file: unction new_excerpt_more( $more ) { return ‘…’; } add_filter(‘excerpt_more’, ‘new_excerpt_more’);November 2, 2017 at 5:59 pm #1374271James
ParticipantIn the-events-calendar/src/functions/template-tags/general.php, the tribe_events_get_the_excerpt function correctly generates an excerpt in the $excerpt variable and ends with a call to apply_filters for the function. However, the function does not have a corresponding add_filter, and I believe this prevents the function from returning anything.
To my knowledge, this bug is consistent across all views as they use the same function, though I think I saw somewhere in the plugin that the developers may have deprecated it. That’s concerning because I’m pretty sure this is the default behaviour. As a temporary workaround before the developers fix this issue properly, if you add in a line containing echo $excerpt; right before the function returns, your excerpts will appear.
-
This reply was modified 8 years, 5 months ago by
James. Reason: More information about views and context
November 3, 2017 at 12:47 pm #1374917Julie
ParticipantJames, thank you for your help! However, I apparently don’t have anything about the excerpt within the general.php file. Would it be located in another file?
I can copy/paste that file here, but not sure it will help?
November 3, 2017 at 1:05 pm #1374929Victor
MemberHi Julie & James!
Thanks for reaching out to us Julie! Let me help you with this.
By default, the list view displays the event excerpt, but it does so by using the tribe_events_get_the_excerpt() function. Is the excerpt not showing in the list view for your site?
You can still use the filters you are using in those snippets you shared. Please note that when calling the excerpt_more filter you might want to set a higher priority to make it work like this:
add_filter('excerpt_more', 'new_excerpt_more', 20);Are those snippets not working for you? Let me know about it.
Additionally, let me share the following article where George explains the trouble with excerpts > https://theeventscalendar.com/the-trouble-with-excerpts/
James, thanks for chiming in to help with this topic. I’m not really sure I understand what you mean when saying “the function does not have a corresponding add_filter, and I believe this prevents the function from returning anything.”
Are you experiencing problems using one of the available filters? If so, please let us know about it by opening a new topic, so we can handle things separately as it seems to be a different issue than Julie’s.
Thanks,
VictorNovember 3, 2017 at 1:25 pm #1374944Julie
ParticipantHi Victor,
Where should I add that code? I have tried both of those snippets in the functions.php and it does not work. Will try yours now, but just want to make sure I’m putting it in the right spot.
Furthermore, I have shared a screenshot. My list view is pretty much a mess. The title is under the picture and there is no description. Check it out. HELP?! I’m at a loss and feel like I’ve been trying.
November 5, 2017 at 9:37 pm #1375762James
ParticipantMy issue disappeared before I was able to verify the root cause. I think that the Avada theme may have had a misconfiguration that I resolved by re-saving its excerpt settings. Sorry for wasting your time.
November 6, 2017 at 5:44 am #1375968Victor
MemberHi Julie!
I’m sorry that’s not working for you.
The code snippet should work by placing it in your active theme’s functions.php file. Please make sure you are using straight quotes in the code, instead of curly quotes. You can also use the My Custom Functions plugin > https://wordpress.org/plugins/my-custom-functions/ which I know some users do. Let me know how it goes.
I wasn’t able to get the screenshots. Please make sure to attach it by using the online form, as you won’t be able to send pictures replying by email.
I can see the issue you mention in your site. This can be related to a theme or plugin conflict, so to narrow the problem down please go through the steps provided in the testing for conflicts guide > https://theeventscalendar.com/knowledgebase/testing-for-conflicts/ and let us know what you find in the process.
Hey James! Glad to know you could solve the issue. Thanks for letting us know and don’t hesitate to open a new topic if needed.
Best,
VictorNovember 6, 2017 at 12:54 pm #1376405Julie
ParticipantHi Victor,
I downloaded the plugin, just to see if that could help (as you’re right, I don’t like editing the functions.php file, so this helps). Anyway, nada. HEEEEELP.
Below is the code I have in your plugin. What’s missing?
Also, when I look at the demo content, it seems to be calling up tribe-events-list-event-description tribe-events-content description entry-summary, which my site does not.
/* display excerpts in list view of calendar */
add_filter( ‘excerpt_length’, ‘custom_excerpt_length’, 999 ); function custom_excerpt_length( $length ) { return 300; }/* attempt to display exerpts again */
function new_excerpt_more( $more ) { return ‘…’; } add_filter(‘excerpt_more’, ‘new_excerpt_more’, 20);November 7, 2017 at 4:59 am #1376806Victor
MemberHi Julie!
Try copy and pasting the following code and see if it works:
/* display excerpts in list view of calendar */
add_filter( 'excerpt_length', 'custom_excerpt_length', 999 ); function custom_excerpt_length( $length ) { return 300; }
/* attempt to display exerpts again */
function new_excerpt_more( $more ) { return '...'; } add_filter('excerpt_more', 'new_excerpt_more', 20);If it doesn’t work, it might be that your theme is customizing the list view template, so that is why you don’t see the event excerpt. To confirm this, please try switching to a default theme like twenty seventeen and see if it shows the excerpt in the list view.
We suggest you setup a dev/staging site so you can make this test without disrupting the live site.
Let me know how it goes.
Thanks,
VictorNovember 7, 2017 at 8:31 am #1376957Julie
ParticipantYep, it’s the theme. I had tried that before and didn’t see it, so not sure what was up then. Looks perfect when I switch themes. Advice on troubleshooting?
November 7, 2017 at 8:41 am #1377066Julie
ParticipantSorry – I inherited this site and am just now digging in as the author of the theme (custom) already has the custom php files within the theme file. So, I’ll try to figure out how to display the content there based on what I see in the demo.
November 7, 2017 at 8:56 am #1377078Julie
Participantokay, it seems like the content.php files are the same that are in the theme folder and the plugins folder, so I cannot figure out where the customization is. If you can lend any advice, that would be great. UGH. I’m so sorry.
November 7, 2017 at 9:21 am #1377109Julie
ParticipantI got it! I just deleted the custom files in the theme. Man, I have been working on that forever and it was that simple! ha.
Thanks for the help.
November 7, 2017 at 11:54 am #1377217Victor
MemberHey Julie!
It’s great to know you could solve the issue! Thanks for following up to let us know about it.
I’ll go ahead and close the thread, but don’t hesitate to open a new topic if anything comes up and we’ll be happy to help.
Good luck with your project!
Victor -
This reply was modified 8 years, 5 months ago by
-
AuthorPosts
- The topic ‘Display Excerpt in List View’ is closed to new replies.
