Remove Events from Archive Listings

Home Forums Calendar Products Events Calendar PRO Remove Events from Archive Listings

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #345288

    Hiya –

    Is there any way to remove events from archive listings? I’m specifically referring to listings of tags (which are shared between posts and events on my site).

    http://illegitimatetheatre.com/tag/region-australia/

    On this page, I would like only posts to be listed – not events generated via Events Calendar Pro.

    Please let me know if you need any other information. I haven’t been able to find this issue listed in the forums.

    Ash

    #356526
    Barry
    Member

    Hi Ash, that should be possible – does the following snippet (which you might add to your theme’s functions.php file) help out here?

    add_action( 'parse_query', 'remove_events_from_tag_query', 75 );
    
    function remove_events_from_tag_query( $query ) {
    	if ( ! $query->is_tag || ! is_array( $query->get( 'post_type' ) ) ) return;
    	if ( ! in_array( TribeEvents::POSTTYPE, $query->get( 'post_type' ) ) ) return;
    
    	$types = $query->get( 'post_type' );
    
    	foreach ( $types as $index => $post_type )
    		if ( $post_type === TribeEvents::POSTTYPE ) unset( $types[$index] );
    
    	$query->set( 'post_type', $types );
    }
    #357339

    Fixed! Thanks for the prompt reply – much appreciated.

    #365317
    Barry
    Member

    Awesome – happy to help 🙂

    I’ll go ahead and close this thread in that case – and, if you have a moment to spare, we’d love to hear your thoughts on The Events Calendar on our review page. Thanks!

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Remove Events from Archive Listings’ is closed to new replies.