Home › Forums › Calendar Products › Events Calendar PRO › Pro Widget Shortcodes – How to include uncategorized events?
- This topic has 8 replies, 4 voices, and was last updated 9 years, 8 months ago by
Riccardo.
-
AuthorPosts
-
August 9, 2016 at 8:03 am #1149410
Riccardo
ParticipantMy calendar has some categories and I have to exclude one category from view; to achieve this I have to include all the categories I want to include except the one I want to exclude. The problem is that also uncategorized events must be included in the shortcode, but I don’t know what syntax to use!
August 9, 2016 at 8:14 am #1149421Riccardo
ParticipantBTW for the main calendar I am using pre_get_posts in my functions.php but it seems the filter is not being applied to the calendar widget
// Removes categories "staff" for non-teachers & non admin $user = wp_get_current_user(); if ( !in_array( 'teacher', (array) $user->roles ) && !current_user_can('administrator') ) { //The user has the "student" or "parent" role add_action( 'pre_get_posts', 'exclude_events_category' ); } function exclude_events_category( $query ) { if ( $query->query_vars['eventDisplay'] == 'list' && !is_tax(Tribe__Events__Main::TAXONOMY) || $query->query_vars['eventDisplay'] == 'month' && $query->query_vars['post_type'] == TribeEvents::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('staff'), 'operator' => 'NOT IN' ) ) ); } }August 10, 2016 at 11:11 am #1150114Andras
KeymasterHi Riccardo,
Thanks for reaching out.
I’m afraid listing events without any category with a shortcode is not possible at the moment. You would need to assign a generic category to those events and then you can include them in the list.
I hope this helps.As for your second question, please allow me some time to look into the issue. I’ll get back to you on that soon. Thanks for your patience!
Cheers,
AndrasAugust 10, 2016 at 3:25 pm #1150266Andras
KeymasterHello again Riccardo,
Thanks for your patience.
If you want to apply the taxonomy query to all event views and widgets then re-write the conditional to the following:
if ( $query->query_vars['post_type'] == TribeEvents::POSTTYPE &&
!is_tax(Tribe__Events__Main::TAXONOMY) &&
empty( $query->query_vars['suppress_filters'] ) ) {
Check this and let me know how that works out.
Cheers,
AndrasAugust 10, 2016 at 3:48 pm #1150275Riccardo
ParticipantWorks perfectly, thanks!
August 11, 2016 at 2:22 am #1150414Riccardo
ParticipantSince I have applied the suggested solution, when debugging is enabled I get the following warning in the page headers:
Notice: Undefined index: post_type in /home/ric965/public_html/me-about.me/wp-content/themes/eduma-child/functions.php on line 326
The offending line seems to be:
if ( $query->query_vars['post_type'] == TribeEvents::POSTTYPE && !is_tax(Tribe__Events__Main::TAXONOMY) && empty( $query->query_vars['suppress_filters'] ) ) {Any idea?
August 11, 2016 at 1:05 pm #1150703Andras
KeymasterHello again,
Try this:
if ( isset($query->query_vars['post_type']) &&
$query->query_vars['post_type'] == TribeEvents::POSTTYPE &&
!is_tax(Tribe__Events__Main::TAXONOMY) &&
empty( $query->query_vars['suppress_filters'] ) ) {
This should do the trick. Let me know the outcome.
Cheers,
AndrasSeptember 2, 2016 at 9:35 am #1159346Support 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 ‘Pro Widget Shortcodes – How to include uncategorized events?’ is closed to new replies.
