Home › Forums › Calendar Products › Events Calendar PRO › Exclude category from events page and paginated pages
- This topic has 5 replies, 2 voices, and was last updated 8 years, 6 months ago by
Lauren Tresp.
-
AuthorPosts
-
September 11, 2017 at 1:24 pm #1347702
Lauren Tresp
ParticipantHello!
We are using the following code in our functions.php file to exclude the “ongoing” category from our events page. However, when the events page is paginated, that category is displaying on subsequent paginated pages (so when we click “page 2”, that category shows up in the event feed). Do you know if there is a way to resolve this? Any help is greatly appreciated!
add_action( ‘pre_get_posts’, ‘tribe_exclude_events_category_month_list’ );
function tribe_exclude_events_category_month_list( $query ) {if ( isset( $query->query_vars[‘eventDisplay’] ) && ! is_singular( ‘tribe_events’ ) ) {
if ( $query->query_vars[‘eventDisplay’] == ‘photo’ && ! is_tax( Tribe__Events__Main::TAXONOMY ) || $query->query_vars[‘eventDisplay’] == ‘month’ && $query->query_vars[‘post_type’] == Tribe__Events__Main::POSTTYPE && ! is_tax( Tribe__Events__Main::TAXONOMY ) && empty( $query->query_vars[‘suppress_filters’] ) ) {
$query->set( ‘tax_query’, array(
array(
‘taxonomy’ => Tribe__Events__Main::TAXONOMY,
‘field’ => ‘slug’,
‘terms’ => array( ‘Ongoing’ ),
‘operator’ => ‘NOT IN’
)
) );
}}
return $query;
}September 12, 2017 at 4:11 pm #1348322Barry
MemberHi there, Lauren!
I’m happy to take a look at this – but I should also point out that we are pretty limited in terms of how much support we can offer for custom code.
The snippet you shared seems like it would work, though, and on testing it out I didn’t have any problems. If I have an event this month in category “Ongoing” and an event next month in that same category, both are removed from month view when the snippet is in place.
If you aren’t finding the same thing, I wonder if perhaps you happen to have month view caching in place (you can find this option in the Events ‣ Settings ‣ Display tab) … sometimes when you are building customizations for month view it’s best to disable this, at least initially.
September 21, 2017 at 1:00 pm #1352993Lauren Tresp
ParticipantThank you for the input! We actually ended up disabling month view and are only using the photo view now. So the issue isn’t switching to a new month, the issue is when the user paginates to the next page of events. We have 42 events displayed in photo view, and when you paginate to see the other events all categories are displayed. So page 1 has all events except “ongoing”, while page 2 displays all events including “ongoing”. Do you have any guidance on how we might remove “ongoing” events on all pages in the main event loop? https://themagsantafe.com/events/?action=tribe_photo&tribe_paged=2&tribe_event_display=photo
September 26, 2017 at 4:05 pm #1355253Barry
MemberAh, I see (and sorry for the delayed response!).
Internally, when pagination happens by ajax, the query is either of the type ‘list’ or ‘past’ but not ‘photo’.
In other words, testing to see if the eventDisplay variable is ‘photo’ will only work on a direct load and not following pagination where the view reloads using an ajax update process.
Catching this scenario at present would require you test to see if it is an ajax request and by inspecting the action key within the $_POST superglobal (if you need to lock things down to photo view).
October 18, 2017 at 9:35 am #1365442Support Droid
KeymasterHey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.
Thanks so much!
The Events Calendar Support Team -
AuthorPosts
- The topic ‘Exclude category from events page and paginated pages’ is closed to new replies.
