You have one or two problems here
-
is_category()
should be object of$query
in your example code -
get_query_var('post_type')
will always return false on a category page AFAIK, so that code is totally unnecessary -
Just a tip, when using
pre_get_posts
with any type of archive, also check for non admin pages as your back end will also be affected by this change
You can try something like this
add_action( 'pre_get_posts', function ( $q ) {
if( !is_admin() && $q->is_main_query() && $q->is_category() ) {
$q->set( 'post_type', array( 'post','event' ) );
}
});