• Resolved davide90

    (@davide90)


    Hello,

    which hook should i have to use for override the query in the list view archive page ?

    • This topic was modified 9 months, 2 weeks ago by davide90.
    • This topic was modified 9 months, 2 weeks ago by davide90.
Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Support Darian

    (@d0153)

    Hi @davide90

    Thanks for reaching out. Let me help you with this one.

    You can use this hook pre_get_posts

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

    Thread Starter davide90

    (@davide90)

    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 9 months, 2 weeks ago by davide90.
    Thread Starter davide90

    (@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 9 months, 2 weeks ago by davide90.
    Plugin Support Darian

    (@d0153)

    Hi @davide90

    Could you try using this condition, and see if that helps?

    if (is_post_type_archive('tribe_events') && tribe_is_list_view())
    Thread Starter davide90

    (@davide90)

    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

    Plugin Support Darian

    (@d0153)

    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.

    Thread Starter davide90

    (@davide90)

    Hi, there are not cache plugin active, probably there is server side cache anyway.

    Plugin Support Darian

    (@d0153)

    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.

    Plugin Support Darian

    (@d0153)

    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.

    Thread Starter davide90

    (@davide90)

    Ok thank you, i will deactivate the server cache and i will see !

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Question about list view’ is closed to new replies.