Question about list view
-
Hi @davide90
Thanks for reaching out. Let me help you with this one.
You can use this hook
pre_get_postsSee example:
function your_function_name( $query ) { if ( tribe_is_list_view() ) { //ADD YOUR CODE HERE } return $query; } add_filter( 'pre_get_posts', 'your_function_name' );As always, please test this first on your staging site to avoid unnecessary downtime to your live site.
I hope this helps, and please let me know if you have further questions or concerns.
Thank you, but with this simple query i just tried for test it breaks the site
if ( tribe_is_list_view() ) { $query = tribe_get_events( [ 'posts_per_page' => 5 ] ); } return $query;-
This reply was modified 2 years, 3 months ago by
davide90.
I have tried this but it doens’t work
function custom_events_list_query($query) { if (class_exists('Tribe__Events__Main')) { if ($query->is_main_query() && is_post_type_archive('tribe_events') && tribe_is_list_view()) { $query->set('posts_per_page', 4); $query->set('ignore_sticky_posts', true); $query->set('post_status', array('publish', 'private')); } } return $query; } add_filter('pre_get_posts', 'custom_events_list_query');-
This reply was modified 2 years, 3 months ago by
davide90.
Hi @davide90
Could you try using this condition, and see if that helps?
if (is_post_type_archive('tribe_events') && tribe_is_list_view())Thank you, it worked, but of course when i change date in datepicker it losts the query, the page is loaded in javascript when i click inside datepicker
Hi @davide90
That’s weird. I tried it on my side, and it did still work after I change the date from the datepicker.
This could be related to caching. If you have a caching plugin or server-side caching, please try to temporarily disable them and see if that makes a difference?
See- https://theeventscalendar.com/knowledgebase/guide/caching-with-the-events-calendar/
If it doesn’t help, please provide the URL of your calendar page. I want to check it further on my side.
Please do not share any credentials, this is for us to follow the WordPress Forum Guidelines.
Hi, there are not cache plugin active, probably there is server side cache anyway.
Hi @davide90
Thank you for your response. Could you please try temporarily deactivating server-side caching to see if that helps?
Let me know if you have further questions or concerns.
Hi there,
It seems like this thread has been quiet for a bit, so we’ll go ahead and mark it as resolved. However, if any further questions or concerns come up, please don’t hesitate to start a new thread.
Ok thank you, i will deactivate the server cache and i will see !
-
This reply was modified 2 years, 3 months ago by
The topic ‘Question about list view’ is closed to new replies.