Pro Widget Shortcodes – How to include uncategorized events?

Home Forums Calendar Products Events Calendar PRO Pro Widget Shortcodes – How to include uncategorized events?

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #1149410
    Riccardo
    Participant

    My 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!

    #1149421
    Riccardo
    Participant

    BTW 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'
    		)
    		)
    	);
    }
    }
    • This reply was modified 9 years, 8 months ago by Riccardo.
    • This reply was modified 9 years, 8 months ago by Riccardo.
    • This reply was modified 9 years, 8 months ago by Riccardo.
    • This reply was modified 9 years, 8 months ago by Riccardo.
    #1150114
    Andras
    Keymaster

    Hi 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,
    Andras

    #1150266
    Andras
    Keymaster

    Hello 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,
    Andras

    #1150275
    Riccardo
    Participant

    Works perfectly, thanks!

    #1150414
    Riccardo
    Participant

    Since 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?

    #1150703
    Andras
    Keymaster

    Hello 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,
    Andras

    #1159346
    Support Droid
    Keymaster

    Hey 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

Viewing 8 posts - 1 through 8 (of 8 total)
  • The topic ‘Pro Widget Shortcodes – How to include uncategorized events?’ is closed to new replies.