Modify ics Export

This topic contains 1 reply, has 2 voices, and was last updated by  Stephen Harris 9 years, 3 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #18532

    Is there any way to modify an export to exclude certain event categories?

    If I buy Pro, is there any way to exclude certain categories when subscribing to the calendar?

    Thanks,

    S.

    Stephen Ogata
    #18539

    Hi Stephen,

    There’s no option, but here’s a snippet that does that:

    add_action( 'pre_get_posts', 'my_exclude_category_from_feed' );
    function my_exclude_category_from_feed( $query ) {
    
        if( $query->is_feed( 'eo-events' ) ){
            $tax_query  = $query->get( 'tax_query', array() );
            $tax_query['relation'] = 'AND';
            $tax_query[] = array(
                'taxonomy' => 'event-category;',
                'field'    => 'term_id',
                'terms'    => array( 103, 115, 206 ), //replace with category IDs
                'operator' => 'NOT IN',
            );
            $query->set( 'tax_query', $tax_query );
        }
    
    }
    

    You’ll need to replace the array of IDs with the IDs of the term(s) you wish to exclude

    Stephen Harris
Viewing 2 posts - 1 through 2 (of 2 total)
To enable me to focus on Pro customers, only users who have a valid license for the Pro add-on may post new topics or replies in this forum. If you have a valid license, please log-in or register an account using the e-mail address you purchased the license with. If you don't you can purchase one here. Or there's always the WordPress repository forum.